Registration form

hi, ive written a registration form ans keep getting two errors. I have been over and over the code and cant see where ive gone wrong. Im only just starting out and probably having bitten off more then i can chew here. Id still like to know where is faulting though if anyone can see.

the errors are :

Notice: Undefined index: Pass in C:\xampp\htdocs\ProjectPHP\Registration.php on line 25

Notice: Use of undefined constant errorMessage - assumed ‘errorMessage’ in C:\xampp\htdocs\ProjectPHP\Registration.php on line 72

<?php

$email = "";
$pass = "";
$errorMessage = "";
$num_rows = 0;

function quote_smart($value, $handle) {

   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   }

   if (!is_numeric($value)) {
       $value = "'" . mysql_real_escape_string($value, $handle) . "'";
   }
   return $value;
}

if ($_SERVER['REQUEST_METHOD'] == 'POST'){

$fname=$_POST['Fname'];
$sname=$_POST['Sname'];
$email=$_POST['Email'];
$pass=$_POST['Pass'];
$country=$_POST['Country'];
				 
$fname=htmlspecialchars($fname);
$sname=htmlspecialchars($sname);
$email=htmlspecialchars($email);
$pass=htmlspecialchars($pass);
$country=htmlspecialchars($country);

//****check for length for each input***//
$flength=strlen($fname);
$slength=strlen($sname);
$elength=strlen($email);
$plength=strlen($pass);
$clength=strlen($country);

if ($flength >= 2 && $flength <= 15) {
	$errorMessage="";
}
else {
	$errorMessage=$errorMessage. "First name must be at least 2 and less then 15 characters"."<br>";
}
if ($slength >= 2 && $slength <= 15) {
	$errorMessage="";
}
else {
	$errorMessage=$errorMessage. "Second name must be at least 2 and less then 15 characters"."<br>";
}
if ($elength >= 10 && $elength <= 50) {
	$errorMessage="";
}
else {
	$errorMessage=$errorMessage. "Email incorrect, Too short"."<br>";
}
if ($plength >= 5 && $plength <= 40) {
	$errorMessage="";
}
else {
	$errorMessage=$errorMessage. "Password must be over 5 characters"."<br>";
}
if ($flength >= 2 && $flength <= 30) {
	$errorMessage="";
}
else {
	$errorMessage=$errorMessage. "To short"."<br>";
}
//connect to the server and db//
if (errorMessage=="") {

$user_name="root";
$pass_word="**********";
$database="projectx";
$server="localhost";

$db_handle=mysql_connect($server, $user_name, $pass_word);
$db_found=mysql_select_db($database, $db_handle);

if(db_found) {
	$sql="SELECT * FROM users WHERE Email = $email";
	$result=mysql_query($sql);
	$num_rows=mysql_num_rows($results);
	
	if($num_rows >0) {
		$errorMessage = "username already exists. Please select another or reset your pasaword";
	}
	else {
		$sql="INSERT INTO users (Fname, Sname, Pass, Email, Country) VALUES ($fname, $sname, md5($pass), $Email, $country)";
		$result=mysql_query($sql);
		mysql_close($db_handle);
			session_start();
			$_SESSION['login'] = "1";

			header ("Location: page1.php");

		}

	}
	else {
		$errorMessage = "Database Not Found";
	}
}
}


?>

the form code is

<form action="Registration.php" method="post" name="Register">
<label>First name:</label> <input name="Fname" type="text" /><br><br>
<label>Second name:</label> <input name="Sname" type="text" /><br><br>
<label>Email (username):</label> <input name="Email" type="text" /><br><br>
<label>Password:</label> <input name="pass" type="text" /><br><br>
<label>Country:</label> <input name="Country" type="text" /><br><br>
<input name="submit" type="submit" />
</form>

thanks in advance

i sorted it, i obviously hadnt read over the script that well. The first error was because i was tryingto post something that wasnt there. All because of a capital letter. was trying to POST Pass, when it was pass. The secon error was it had milled the dollar sign from a variable.

Sponsor our Newsletter | Privacy Policy | Terms of Service