require_once("/home/users/web/b1565/pow.daviddude/htdocs/functions.php"); do_header("Grades", "../Student_Tools/menu.txt"); ?> $error_text = ""; if($create_attempt) { if($studentid=="" || $pin=="" || $username=="" || $password=="" || $password2=="") { $error_text .= "
All fields must be completed.
"; } if($password != $password2) { $error_text .= "Passwords don't match.
"; } $conn = db_connect() or die("Error connecting to database. ".mysql_error()); $result = mysql_query("SELECT * FROM StudentInfo WHERE user_id = '$studentid' AND pin = '$pin'") or die("Error querying database. ".mysql_error()); if (mysql_num_rows($result)!=1) { $error_text .= "That is not a valid combination of Student ID and PIN.
"; } if($username != "" && !ereg("^[a-zA-Z0-9]{5,50}$",$username)) { $error_text .= "Usernames must be between 5 and 50 characters long and can only contain letters and numbers.
"; } if($password != "" && !ereg("^[a-zA-Z0-9]{5,50}$",$password)) { $error_text .= "Passwords must be between 5 and 50 characters long and can only contain letters and numbers.
"; } if($error_text != "") { echo $error_text; echo "Please go back and try again.
"; do_footer(); exit; } $result = mysql_query("INSERT INTO AlternateLogin SET user_id = '$studentid', username = '$username', password = '$password'") or die("That username is already in use. Please try something else.
"); if ($result) { echo "Username successfully created.
"; } else { echo "Error creating username. Please try again later.
"; } } else $show_form = 1; if($show_form) { //display login form ?>