PHP Forms
| From: | Chiew, Richard | Date: | Mon, 25 Feb 2002 18:31:15 +0000 |
| Subject: | PHP Forms | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-86131@lists.php.net to get a copy of this message | ||
I have the following php code to asks for a new student to fill out a
registration form. Using php, take what the user enters and put it into
the "students" table. But when i select * from students in mysql, it
didn't show, why?
<HTML>
<BODY bgColor=#ffffff>
<?php
if ($submit) {
// process form
$db = mysql_connect ("localhost", "root", "mollier");
$select=mysql_select_db ("mydb");
$sql = "INSERT INTO students
(student_id, firstname,lastname, address) VALUES
('$student_id', '$firstname', '$lastname',
'$address')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<FORM onsubmit="return formvalidation(this)"
action="<?php echo $PHP_SELF?>"
method=post><INPUT type=hidden value="New Student Registration - BBS"
name=FORM_NAME>
<P style="LINE-HEIGHT: 100%; BACKGROUND-COLOR: #0000ff"
align=center><B><FONT
color=#ffffff size=5><BR>REGISTRATION
FORM<BR><BR></FONT></B></P>
<PRE><B>
<FONT color=#ff0000>REQUIRED QUESTIONS:</FONT></B>
<BR>
1. What is your student id number? <INPUT tabIndex=2
maxLength=46 size=46 name=student_id><BR>
2. What is your name?<BR>
First name:<input type="Text" name="firstname"><br>
Last name:<input type="Text" name="lastname"><br>
Address: <input type="Text" name="address" size="60"><BR>
</PRE>
<UL>
<LI>
<P style="BACKGROUND-COLOR: #ffffff"><font
color="#FF3300">Please
click
the Submit Button only once</font> </P>
<LI>
<P style="BACKGROUND-COLOR: #ffffff"><font
color="#FF3300">Then
wait for
your confirmation screen</font> </P>
<LI>
<P style="BACKGROUND-COLOR: #ffffff"><font
color="#FF3300">Save
the confirmation
screen because it has information you will need</font> </P>
</LI></UL>
<P style="BACKGROUND-COLOR: #ffffff"><INPUT type=submit value="Submit
Registration"> </P>
<P style="BACKGROUND-COLOR: #ff0000" align=center>End of Form-Thank
You!</P></FORM>
<HR>
<H5 style="BACKGROUND-COLOR: #ffffff"> </H5>
<?php
} // end if
?>
</BODY></HTML>