Jump to content

HTML form action posting to php file


aikorei

Recommended Posts

I'll throw you all a softball, since I'm sure this has to be easy and I'm just daft...

 

All I'm trying to do is create an html form that posts data to a php file on my server. But the php file isn't a webpage. It's just a file in one of my subfolders.

 

When I put what I believe the absolute url to the file on my server in as the action, it brings me to a blank white page and nothing happens.

 

I believe I get the concept of using $_POST to get the information and handle it....but how do I get it to the file?

Link to comment
https://forums.phpfreaks.com/topic/275892-html-form-action-posting-to-php-file/
Share on other sites

<form action="myfolder/myphpfilename.php" method="POST">
<input type="text" name="myfieldname">
.... many more fields here if you need them.

<input type="submit">

</form>

To see something when you access your php file you need the php to output something.

Try adding this code

echo 'Hi there <br />';
echo $_POST['myfieldname'];

to see how it works.

I just realized that my php errors were printing to an error_log I didn't realize I had (in a different folder than the main error_log I usually check). There was a syntax error that was blocking the file from loading right.

 

I had been trying to echo something to the page, and it wasn't working...now it is. I guess the right syntax makes a difference. =P

 

Thanks for the help anyhow!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.