thesavior
06-10-2006, 05:10 PM
I have my code:
mysql_connect($db_host, $db_username, "newpwd");
mysql_select_db("powersoft");
$username = $_POST['username'];
$username = mysql_real_escape_string($username);
if ($username == '') exit ('You must enter a username');
$password = $_POST['password'];
if ($password == '') exit ('You must enter a password');
if ($password == 'Password') exit ('You must enter a password');
$encpassword = md5($password);
$email = $_POST['email'];
if (email == '') exit ('You must enter an email address');
if (email == 'E-mail') exit ('You must enter an email adress');
$email = mysql_real_escape_string($email);
$ip = $_SERVER['REMOTE_ADDR'];
$sql = 'INSERT INTO `admin_login` (`id`, `username`, `password`, `email`, `ip`, `user`) VALUES (NULL, \''.$username.'\', \''.$encpassword.'\', \''.$email.'\', \''.$ip.'\', \'1\');';
mysql_query($sql) or die (mysql_error());
and i want to run a check before I insert into the database whether there are any other rows with either that username, that email, or both and return an error and stop if there is. What query would I run for that and where would I put it?
mysql_connect($db_host, $db_username, "newpwd");
mysql_select_db("powersoft");
$username = $_POST['username'];
$username = mysql_real_escape_string($username);
if ($username == '') exit ('You must enter a username');
$password = $_POST['password'];
if ($password == '') exit ('You must enter a password');
if ($password == 'Password') exit ('You must enter a password');
$encpassword = md5($password);
$email = $_POST['email'];
if (email == '') exit ('You must enter an email address');
if (email == 'E-mail') exit ('You must enter an email adress');
$email = mysql_real_escape_string($email);
$ip = $_SERVER['REMOTE_ADDR'];
$sql = 'INSERT INTO `admin_login` (`id`, `username`, `password`, `email`, `ip`, `user`) VALUES (NULL, \''.$username.'\', \''.$encpassword.'\', \''.$email.'\', \''.$ip.'\', \'1\');';
mysql_query($sql) or die (mysql_error());
and i want to run a check before I insert into the database whether there are any other rows with either that username, that email, or both and return an error and stop if there is. What query would I run for that and where would I put it?