username verification part 2
Posted: Mon Jun 24, 2002 10:51 am
I've tried several different things with this, and the code I currently have does not report an error message if the user enters an already in-use password, it just refreshes the form page. Here is the code I have:
The form is on the same page and just echoes itself.
Code: Select all
<? //initilize PHP
include("webvars.inc");
mysql_connect("$hostname","$user","$pass") or die(); //connect
mysql_select_db("pancorp"); //select db
if($submit) {
$usertest = $_POSTї'username'];
$sql = "SELECT username FROM technicians WHERE username = '$usertest'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) != 0) {
echo 'Username taken, please choose another username.';
}
else {
$sql2 = "INSERT INTO technicians (id,username,password,firstname,lastname,email,location,phonenumber)".
"VALUES ('NULL', '$username', '$password', '$firstname', '$lastname', '$email', '$location', '$phonenumber')";
$result=mysql_query($sql2) or die(); //Insert into db
header ("location: http://www.pancorp.com/techs/thanks.php");
}
}
mysql_close();
?>