PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am new to this forum and to PHP. I have absolutely no idea how it works and thought would get some help.
I was developing a personal website and wanted to get feedback from my visitors in a HTML form.
This is the simplest form that I am trying as a beginner. I am using the method as Post in my HTML code and wanted to know how I create a PHP file so that the information my user inputs gets stored. For example if I have the code as below:
-tag added][/size]
How do I create my formresponse.php file ?
My server operating system is Linux which uses PHP 4.3.3.
Hope I have made myself clear as to what I am looking for.
Thanks for your help.
that provides answer to the speciifc php file is posted
Your form has the action-property "post", so in your php-script the values will be stored in the superglobal array $_POST.
E.g. <input type="text" name="email" size="40"> $_POST['email']
You got me right. In fact that was my question. How and where does the data entered by the user gets stored ?? I believe that it gets stored in the formresponse.php that i would have to upload to my root folder in my server.
My question was How do I create the formresponse.php file.
The formresponse.php file is just like any other PHP file. At the top of the page you can use the posted variables (like $_POST['email'] or $_POST['name'] ) and do whatever you want with them.
<?php
if (empty($_POST['name']))
{
echo "You didn't enter a name!";
}
else
{
//keep going
//You can put the info into a database after you have checked the validity of it
$query = "INSERT INTO table VALUES ('$POST['name']','$POST['email']','$POST['Place']','$POST['website']','$POST['comments']')";
$result = mysql_query($query);
}
?>
Edit:
Just saw your post regarding the email. I'm not sure about that but instead of inserting the data into a database as shown above you could just email it to your self using PHP. Check out the mail() function.
Although I haven't understood it fully, I wil try it out. when I tried to test it by entering data and clicking on the submit button, I get the error "file Not found".
I uploaded the php file to my cgi-bin. Assuming that it works how do I view the information. sorry if I am asking toooooo stupid questions. This is new to me, but I want to try it out.
The two files must be in the same folder and can be in any folder that you want. PHP files are not restricted to the cgi-bin. If you want to see all the information that is passed from the HTML form page to formresponse.php you could do this: