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

post php

<?php
echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
?>
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 :: file upload in php mysql 
Php :: laravel pluck relationship 
Php :: get user information woocommerce 
Php :: php echo variable 
Php :: create request laravel command 
Php :: codeigniter order_by 
Php :: php add element to array 
Php :: wc_product_attribute set_options value 
Php :: echo php 
Php :: uppercase php 
Php :: php cookie 
Php :: how to use php to print inside html 
Php :: wordpress add new page programmatically 
Php :: check if array contains only unique values php 
Php :: laravel parent child same table 
Php :: is_unique in codeigniter form validation 
Php :: check for headers laravel 
Php :: laravel get mysql column datatype 
Php :: mac brew install php redis 
Php :: laravel return view with multiple variable 
Php :: json_decode 
Php :: add custom attribute for validation errors laravel 
Php :: laravel download file from s3 
Php :: laravel controller create command in a folder 
Php :: Error: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress. 
Php :: assign $variable of key value pair array to multiple variables php 
Php :: php showing code in browser 
Php :: wordpress deactivate widgets gutenberg 
Php :: how to link image in laravel 
Php :: add json extenstion php 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =