Question
why will this code not work? Chinese Zodiac Networking body, .navbar navbar-default { backgroung-color: rgb(235,244,251); } Toggle navigation Chinese Zodiac Social Networking Login Register Register
why will this code not work?
session_start();
if(isset($_SESSION['member_id']))
{
header("Location:index.php");//redirects to the home page
} // ends isset session
//insert the connection script and end the script if the connection fails
require_once '../../../../../inc_connect.php';
//function to store password as a hashed value
function randomString()
{
$string = md5(rand());
return $string;
}
//initially there are no erros
$error = false;
//check if form s submitted
if(isset($_POST['register']))
{
$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$cpassword = mysql_real_escape_string($_POST['cpassword']);
//validate form data
//fname can contain only letters and spaces
if(!preg_match('/^[a-zA-Z\s]+$/',$fname))
{
$error = true;
//message to member if error occurs
$fname_error = "Name must contain only letters and spaces";
}
//lname can contain only letters and spaces
if(!preg_match('/^[a-zA-Z\s]+$/',$lname))
{
$error = true;
//message to member if error occurs
$lname_error = "Name must contain only letters and spaces";
}
//validate email to valid maine account
if(!preg_match('/^[a-zA-Z\.]+@(unit\.maine|maine)\.edu/', $email))
{
$error = true;
//message to member if error occurs
$email_error = "Please enter a valid University account.";
}// ends email
//text striing with at lease one Number and one Character between 6 and 10 characters
if(strlen($password) < 7)
{
$error = true;
$password_error = "Password must be minimum of 7 characters.";
}
if($password != $cpassword)
{
$error = true;
//messare to member if error occurs
$cpassword_error = "Password and Comfirm Password do not match.";
}
if(!$error)
{
//hash and salt the password to make it more secure
$hash = "";
$password = $_POST['password'];
$salt = randomString();
$hash = md5($password.$salt);
$TableName = "members"; //assign the table name to a variable
//insert posted data to the mebers table
$SQLString = "INSERT INTO $TableName " .
"(fname, lname, password_hash, password_salt) VALUES" .
"('$fname', '$lname', '$email', '$hash', '$salt')";
$QueryResults = @mysql_query($SQLString, $DBConnect);
if($QueryResults)
{
//message on successful registration
$successmsg = "Successfully Registered! Click here to Login";
}//ends if QR
else
{
//message on uncuccessful registration
echo mysql_error();
$errormsg = "Error in registering... Pleae try again later!.";
}//ends else QR
}//ends if !$error
}//ends isset for register
?>
body, .navbar navbar-default
{
backgroung-color: rgb(235,244,251);
}
Toggle navigation
Chinese Zodiac Social Networking
Already Registered? Login Here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started