tigerfang
10-17-2004, 08:06 PM
Hey everyone...
I'm just learning php and am using forms to load data into a database.... now, before you go saying that this is in the wrong topic, please read on.... My problem is that I have a form on one page, and a submit button. When the user submits the form, the page in the "action" property is loaded... however it seems like the data from the form isn't carried over. Can anyone help me?
Here is my form code:
<form method="post" action="create_entry.php">
<b>Name:</b><input type=text size=40 name=name><br>
<b>Location:</b><input type=text size=40 name=location><br>
<b>Email:</b><input type=text size=40 name=email><br>
<b>Home Page URL:</b><input type=text size=40 name=url><br>
<b>Comments:</b>
<textarea name=comments cols=40 rows=4 wrap=virtual></textarea>
<br>
<input type=submit name=submit value="Sign!">
<input type=reset name=reset value="Start Over">
</form>
and here is the php that handles the request on the next page...
<?php
include("dbconnect.php");
if($submit=="Sign!")
{
$query = "insert into guestbook
(name,location,email,url,comments) values
('$name','$location','$email','$url','$comments')"
;
mysql_query($query) or
die (mysql_error());
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View Guestbook</a></h2>
<?php
}
else
{
echo "Error<br>";
//include("sign.php");
}
?>
Thanks for any help...
Michael
I'm just learning php and am using forms to load data into a database.... now, before you go saying that this is in the wrong topic, please read on.... My problem is that I have a form on one page, and a submit button. When the user submits the form, the page in the "action" property is loaded... however it seems like the data from the form isn't carried over. Can anyone help me?
Here is my form code:
<form method="post" action="create_entry.php">
<b>Name:</b><input type=text size=40 name=name><br>
<b>Location:</b><input type=text size=40 name=location><br>
<b>Email:</b><input type=text size=40 name=email><br>
<b>Home Page URL:</b><input type=text size=40 name=url><br>
<b>Comments:</b>
<textarea name=comments cols=40 rows=4 wrap=virtual></textarea>
<br>
<input type=submit name=submit value="Sign!">
<input type=reset name=reset value="Start Over">
</form>
and here is the php that handles the request on the next page...
<?php
include("dbconnect.php");
if($submit=="Sign!")
{
$query = "insert into guestbook
(name,location,email,url,comments) values
('$name','$location','$email','$url','$comments')"
;
mysql_query($query) or
die (mysql_error());
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View Guestbook</a></h2>
<?php
}
else
{
echo "Error<br>";
//include("sign.php");
}
?>
Thanks for any help...
Michael