I tried incorporating this into another test script but can not figure out why the Line 39 error keeps happening.
Help! Thanks.
<?
?>
<HTML>
<HEAD></HEAD>
<BODY></BODY>
<?php
if($_POST['submit']) {
$errors = array();
function Check_Field($field) {
global $errors;
if(!isset($REQUEST[$field])) {
$errors[] = "Internal error... a field seen not to have been sent.";
} else if(trim($REQUEST[$field]) == "") {
$errors[] = "The fields \"$field\" has not been filled.";
}
}
}
// Examples... <<
Check_Field("firstname");
Check_Field("lastname");
// >> End of examples
if(count($errors) > 0) {
echo "One or some errors have occured :<BR />\n";
for($i = 0; $i < count($errors); $i++) {
echo $errors[$i] . "<BR />\n";
}
} else {
// Verification is done and no error has occured.
$db = mysql_connect("localhost", "me","");
mysql_select_db("mydb",$db)
or die ("Unable to connect to server at this time.");
$sql = "INSERT INTO names (firstname, lastname) VALUES ($POST['firstname'], $POST['lastname'])";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
else
{
?>
<form method = $_SERVER['PHP_SELF'] method="post">
First name:<input type="text" name="firstname"><br>
Last name:<input type="text" name="lastname"><br>
<input type="Submit"name="submit" value=" Enter information"></form>
<?
}
?>
</BODY>
</HTML>
<?
?>