i have added the $random in line 53 and '$random' ,'0' in 57 line inside the (),in the database i have added random and activated with boolean value which is 0 or 1,and when i click the previu/debug in browser button it show me this: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\site 2\register.php on line 22
Please fill in all fields!
when i click in another page the register link i open normaly not like this,where is the problem??
<?php
$submit = @$_POST['submit'];
//form data
$fullname = strip_tags (@$_POST['fullname']);
$username = strtolower(strip_tags (@$_POST['username']));
$password= strip_tags(@$_POST['password']);
$repeatpassword = strip_tags(@$_POST['repeatpassword']);
$date =date("Y-m-d");
if ($submit)
// open database
$connect = mysql_connect("localhost","root","");
mysql_select_db("phplogin"); // select database
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);
if ($count !=0)
{
die ("Username is already taken!");
}
{
// check for existance
if($fullname&&$username&&$password&&$repeatpassword)
{
if($password==$repeatpassword)
{
//chechk char length of username and fullname
if (strlen($username)>25||strlen ($fullname)>25)
{
echo ("Length of username or fullname is too long!");
}
else
{
//check password length
if(strlen($password)>25||strlen ($password)<6)
{
echo ("Password must be between 6 and 25 characters");
}
else
{
//register the user!
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
//generate random number for activation processes
$random = rand(23456789,98765432);
$queryreg =mysql_query("
INSERT INTO users VALUES ('','$fullname','$username','$password','$date','$random','0')
");
die ("You have been registered!<a href='index.php'> Return to Login page</a>");
}
}
}
else
echo ("Your password do nat match!");
}
else
echo("<b>Please fill in all</b> fields!");
}
?>