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 :: Using the PHPExcel library to read an Excel file and transfer the data into a database 
Php :: php get html with special characters 
Php :: add action hook 
Php :: php get array key 
Php :: Codeigniter 3 Pass anything in query string 
Php :: wordpress change slug programmatically 
Php :: how to get length array in php 
Php :: spatie activity log 
Php :: resize image using intervention laravel and save 
Php :: laravel validation check foreign key exists 
Php :: laravel drop column softdeletes 
Php :: php str starts with 
Php :: Parse error: syntax error, unexpected token "{" in C:xampphtdocsloginsystem1welcome.php on line 3 
Php :: add character after x characters in php 
Php :: softdelete laravel 
Php :: laravel datatables 
Php :: laravel seeder with relationships 
Php :: fakestore api data in laravel 
Php :: cf7 remove p tags 
Php :: php string variable 
Php :: AuthController 
Php :: download pdf file from database in php 
Php :: empty func php 
Php :: no cache hummingbird 
Php :: adjacent post sort order by post title 
Php :: wp wc php if not is single product page 
Php :: echo placeholder image if post thumbnail not found 
Php :: eloquent firstorcreate 
Php :: PHP sprintf — Return a formatted string 
Php :: laravel roles and permissions 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =