simple validation - newbie question
Posted: Tue May 28, 2002 5:48 pm
hi guys,
tryin to get this validation script off the ground to check for the presence of the user_id field. Im unsuccesful in doing so as the record is still created in the database regardless of if the user_id field is complete or blank.
Please do not laugh
Any help as to where i've gone wrong is much appreciated
thank you
tryin to get this validation script off the ground to check for the presence of the user_id field. Im unsuccesful in doing so as the record is still created in the database regardless of if the user_id field is complete or blank.
Please do not laugh
Code: Select all
<?php
if ($submitted) {
$query = "insert into student_table "
." (user_id, first_name, last_name, course_id) values "
."('$user_id', '$first_name', '$last_name', '$course_id')"
;
$result = mysql_query($query);
if($result) {
echo "submission succesful"; }
else {
echo "error";
}
} else {
print ("You need to enter the user_id"); }
?>
<head>
</head>
<form method=post action="../create_student_entry.php">
<input type=hidden name="submitted" value="true">
<div align="left">
<pre><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">User ID:</font></b><font size="1"> </font> <input type=text size=5 name=user_id maxlength="5">
<b><font face="Verdana, Arial, Helvetica, sans-serif"><font size="1">First Name:</font> </font></b><input type=text size=20 name=first_name>
<font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Last Name:</font></b></font> <input type=text size=15 name=last_name>
<b><font face="Verdana, Arial, Helvetica, sans-serif"><font size="1">Course ID:</font> <select size="1" name="course_id"><option selected>Please Select Course</option><option value="G618">Media Communication Systems</option><option value="G600">Computer Systems Engineering</option><option value="H6H5">Electrical & Electronic Engineering</option></select></font></b>
<input type=submit name=submit value="Submit"> <input type=reset name=reset value="Clear"> </pre>
</div>
</form>
<p> </p>thank you