What's wrong with my PHP code ?

  • Thread starter Thread starter Bleah
  • Start date Start date
B

Bleah

Guest
The part that doesn't work is the part that looks for other usernames the same as the one before it.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

<?php
if ($_POST['password'] != $_POST['confirmpassword'])
{
$nomatch = "The passwords didn't match.";
}
else {
$username=$_POST['username'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];

$con = mysql_connect("****","****","****");
}
if (!$con)
{
die(" The passwords didn't match. Please go back and try again.");
}



$con = mysql_connect("****","****","****");
$find = "SELECT * FROM login WHERE username='$username'";
$result = mysql_query($find);
$numfound = mysql_num_rows($result);

if ($numfound==0)
{
mysql_query("INSERT INTO login (username,password) VALUES ($username,$password)");
echo "Your account has been created, $username ";
}
else {
$taken = "This username is already taken";
echo $taken;
}
?>
 
Back
Top