For some reason, I'm getting the error that I can't connect to my DB. I'm sure I'm missing something obvious. Any ideas?
<?PHP
error_reporting(7);
#----------
Validate: String
function check_string($value, $low, $high, $mode, $optional)
{
if ( (strlen($value) == 0) && ($optional === true) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == 1) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == 2) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == 3) ) {
return true;
} else {
return false;
}
}
#----------
Validate: Email
function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === true) ) {
return true;
} elseif ( eregi("[a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)(.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
RegisterGlobals OFF
$FTGFirstName = $POST['FirstName'];
$FTGEmailAddress = $POST['EmailAddress'];
$FTGSubmit = $_POST['Submit'];
Fields Validations
$validationFailed = false;
if ( (! check_string($FTGFirstName, 1, 0, 1, false))) {
$validationFailed = true;
}
if ( (! check_email($FTGEmailAddress, false))) {
$validationFailed = true;
}
Redirect user to the error page
if ($validationFailed == true) {
header("Location: form1.html");
exit;
}
Dump field values to a MySQL table
$DBhost = "localhost";
$DBuser = "***";
$DBpass = "***";
$DBName = "ZKCemails";
$table = "Over13";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table
VALUES('$FirstName','$EmailAddress')";
$results = mysql_query($sqlquery);
mysql_close();
End of PHP script
?>