简体   繁体   中英

PHP post data to an HTTPS page

I have a https page named user.php that gets data and posts it to another receiving.php https page. My problems is whenever I submit my data for posting the receiving.php displays server error. I have read articles about cURL but I don't have a clear picture of the syntax.

user.php

<form action="https://www.mydomain.com/ssl/receiving.php"> 
<input type="text" name="variable" />
<input type="submit" name="buttonName" />
</form>

receving.php

if(isset($_POST["buttonName"]))
{
$variable=$_POST['variable'];

}

You want to add method="POST" to your form tag. By default it'll submit through GET. If that doesn't work, try var_dump($_POST) in receiving.php to see exactly what's coming through. cURL is mainly for when you want a script to make a request to a server on its own. A form submit shouldn't need to worry about cURL.

What error are you receiving though? This shouldn't display an error as your isset() should just return false.

you need to use the $_GET method instead of $_POST because $_GET is a method that displays your request in the form in URL. while $_POST for security reason is just getting data from the form and not displaying the actions you've requested.

<form action="https://www.mydomain.com/ssl/receiving.php">

if you want to use $_POST you need to make your form method set to method="POST" or by default your method form is using "GET".

So you instead of using $_POST , you need to use $_GET in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM