Sorry for the bump, it seems the forum has a time limit before you can't edit a post anymore which is why I am posting this instead of editing my previous post:
I was debugging my form earlier and decided to add echoes due to it's strange behavior to see if I could tell where it's getting stuck. I added echoes after specific events so I could tell where the code stops processing.
The code appears to be getting stuck on the preg_matches, here is the php part of the code. Other than the echoes I haven't changed any code from my previous post. If I fix the problem I'll report back:
php Code:
<?php
if (isset($_POST&
#91;'submitted'])) { echo "Successful submit!";
require_once('../includes/sanitize.php');
//Sanitize data before validation
$c_fname = sanitize(3, 15, $_POST['first_name']);
$c_lname = sanitize(3, 25, $_POST['last_name']);
$c_email = sanitize(5, 60, $_POST['email']);
$c_email_2 = sanitize(5, 60, $_POST['email_2']);
echo "Sanitization complete!";
//Validate the first name
return preg_match("/^[a-zA-Z\.]{1,15}/",
$c_fname);
echo "Preg_match for first name should have worked!";
//Validate last name
[a-zA-Z\-.]{1,25}/", $c_lname);
echo "Name(s) validated!";
//Is the email valid and not empty?
echo '<p>Please enter your email address in both fields.</p>';
} else if ($c_email != $c_email_2) {
echo '<p>The email fields do not match. Please confirm them again.</p>';
} else {
function isValidEmail( $c_email = null ) {
[\d\w\/+!=#|$?%{^&}*`'~-]
[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
[A-Z0-9]
[A-Z0-9.-]{1,60}
[A-Z0-9]\.
[A-Z]{2,6}/", $c_email);
}
}
echo "Emails are valid!";
if (!
empty($c_email) &&
$c_email ==
$c_email_2) { $access = "SELECT Email FROM customers WHERE Email='$c_email'";
$r = mysqli_query
($dbc,
$access) or
trigger_error("Query: $access\n<br />MySQL error: " . mysqli_error
($dbc));
}
//Insert information if email is unique:
if (mysqli_num_rows($r) == 0) {
$access = "INSERT INTO customers (Email, First, Last) VALUES ('$c_email', '$c_fname', '$c_lname')";
$r = mysqli_query
($dbc,
$access) or
trigger_error("Query: $access\n<br />MySQL error: " . mysqli_error
($dbc));
} else {
echo '<p>Your email address could not be recorded due to an error, please try again.</p>';
}
mysqli_close($dbc);
} // End Submit IF.
?>