Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php post

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Name: <input type="text" name="fname">
  <input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  // do logic
  $name = $_POST['fname'];
}
?>
Comment

php post request

$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');

// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded
",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

var_dump($result);
Comment

php send post request

// CURL-less method with PHP5
$context  = stream_context_create(array(
  	// use key 'http' even if you send the request to https
    'http' => array(
      	//'header' and 'content' is optional
        'header'  => "Content-type: application/x-www-form-urlencoded
",
        'method'  => 'POST',
        'content' => http_build_query(
          array('key1' => 'value1', 'key2' => 'value2')
        )
    )
));
$result = file_get_contents('http://server.com/path', false, $context);
if ($result === FALSE) { 
	echo "an error occurred during post.";
    http_response_code(500);
} else {
  	// success
	var_dump($result);
}
Comment

Php post request

<html>  
   <body>  
     
      <form action = "posttest.php" method = "post">  
         Username: <input type = "text" name = "username" /> <br>  
         Blood Group: <input type = "text" name = "bloodgroup" /> <br>  
         <input type = "submit" />  
      </form>  
        
   </body>  
</html>  
Comment

php post http

<?php
form action
?>
Comment

PREVIOUS NEXT
Code Example
Php :: yajra add column 
Php :: ajax php example 
Php :: wc php get order get coupon discount amount 
Php :: publish laravel scout 
Php :: php ?: 
Php :: nodejs php 
Php :: laravel scope query 
Php :: current date time in php for input 
Php :: prestashop get product id 
Php :: php trait 
Php :: laravel array update 
Php :: how to install mysql and phpmyadmin on windows 10 
Php :: how use variable in string in laravel 
Php :: how to host a php server 
Php :: how to convert youtube video to mp3 in php 
Php :: how to save array of inputs in php 
Php :: add column to matrix php 
Java :: java get screen size 
Java :: printing hello world in java 
Java :: import android.support.v7.app.ActionBarActivity; 
Java :: full screen in jframe 
Java :: java filewriter new line 
Java :: java iterate through hashmap 
Java :: java try catch integer.parseint 
Java :: stringjoiner stream java 
Java :: converting string to int java 
Java :: Json web token dependency in Maven 
Java :: java create txt file 
Java :: java remove file extension from file name 
Java :: java bubble sort 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =