Jump to content

HTML form action posting to php file


aikorei
Go to solution Solved by 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
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.

Edited by davidannis
Link to comment
Share on other sites

  • Solution

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!

Edited by aikorei
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.