I searched thru all the PHP threads I could find relating to PHP & Forms and didn't quite find anything like what I asking. I am new to PHP and was wondering if someone could let me know why I am getting error HTTP 404 (Not Found)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<body>


<form method="post" action="<?php echo $PHP_SELF?>">

First name:<input name="name" ><br>

Last name:<input name="email" ><br>

<input type="submit" name="submit" value="submit">
</form>


</body>

</html>

try action="<?php echo $_SERVER; ?>"

I still get the same error. the code now looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<body>


<form method="post" action="<?php echo $_SERVER; ?>">

First name:<input name="name" ><br>

email:<input name="email" ><br>

<input type="submit" name="submit" value="submit">
</form>


</body>

</html>

umm.. I hope you have started apache service and you are executing your script like, http://localhost/yourfilename.php ? When are you getting that error ? After you submit the page ? What is your url ?
PS. Next time you post your code, please wrap it within [ code=php] [ /code] tags.

no, I found this code on the internet and thought I would try to get it to work before I moved to the next step. I will go get a book. can you recommend one? I have a url, but it is in the very beginning stages

No. What I am asking you is, how do you execute your script ? Are you double clicking the file or are you typing the path in the address bar ?
Well, If you want to learn the basics of php, w3schools is the best site to start off.

I double click on the file from the website and fill in the boxes and submit.

All I really want to end up with at this point is a form the user inputs a name, email and maybe a comment. on submit the data will end up in the mySQL database. The web hosting supports PHP and mySQL. I've done some SQL programming so that will be easier for me to figure out. I also have a CIS degree, but I don't have any experience with web sites at all (other than surfing the net).

Once I get the above code to work, my next step was to add the code for mysql_connect, etc

thanks, jenny

hmm. Try this script. Tellme if it works.

<?php
if(isset($_POST['submit'])){
  print_r($_POST);
}
?>
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="name"><br />
<input type="text" name="email"><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Call this test.php, put it on your server. Tellme if it works.

it actually liked that code

I'm now getting error messages

Parse error: syntax error, unexpected '{' in /home/n9m4teaw/public_html/test.php on line 2


So what does this mean? should I be using a .php for my code?

Yep. You should have an extension .php for your scripts if you want apache to parse php. Can you show us the script you are using ? (because the code example that I gave you shouldn't give this error!)

I copied and pasted your exact script with the exception of the first line (<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">). Was I not supposed to put the first line? Also, your text didn't look as nice as what you gave me. It looked like below, but I didn't want to add anything to it that might cause problems. so I left it just like this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<?phpif(isset($_POST)){ print_r($_POST);}?><html><body><form method="post" action="test.php"><input type="text" name="name"><br /><input type="text" name="email"><br /><input type="submit" name="submit" value="submit"></form></body></html><?php
if(isset($_POST)){
print_r($_POST);
}
?>
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="name"><br />
<input type="text" name="email"><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

sorry, i forgot the <code - PHP tags you said I should use

ok, I used the tags

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<?phpif(isset($_POST['submit'])){  print_r($_POST);}?><html><body><form method="post" action="test.php"><input type="text" name="name"><br /><input type="text" name="email"><br /><input type="submit" name="submit" value="submit"></form></body></html><?php
if(isset($_POST['submit'])){
  print_r($_POST);
}
?>
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="name"><br />
<input type="text" name="email"><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
  print_r($_POST);
}
?>
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="name"><br />
<input type="text" name="email"><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Click on "toggle plain text" and then copy the code. :) And I meant [ code=php] [ /code] ! < without the whitespace.

Array ( [name] => jenny [email] => vbjenny@msn.com [submit] => submit )

Thank you very much.

You are awesome!!!!!!!!!!!!!

Great. That should get you started. Remember, the file extension should be .php for apache to parse it as a php file. And w3schools will help you learn the basics in no time. You can also refer to php.net.
Its 8 am and I should get some sleep now.. Lol..

Cheers,
Naveen

I just noticed you are from India. It wasn't until you mentioned what time it was that I looked. very cool. I'm from Hermosa Beach, California USA

;)

I just added my first record to the database!!!!!!!!!!!!!!!!1 :)

You were such a big help yesterday and the W3Schools is a very good website. Thank you for recommending it.

I used 2 pages. the first a .htm page for the form and the 2nd a .php to post to the database.


:) :) :) :) :) :) :) :) :) :) :) :) :) :)

:) Good !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.