$rowcount and $count in pdo

i tried verifying some factors in my registration page using row count and count, but its not working, when the page is submitted , it returns a blank page, though the posted form item are available. please any help

<?php
echo "<h2>Register</h2>";

$submit = $_POST['register'];
//form data
$fullname = $_POST['fullname'];
$username = $_POST['username'];
$password = $_POST['password'];
$repeatpassword = $_POST['repeatpassword'];
$email = $_POST['email'];
$houseno = $_POST['houseno'];
$addressa = $_POST['addressa'];
$addressb = $_POST['addressb'];
$addressc = $_POST['addressc'];
$county = $_POST['county'];
$state = $_POST['state'];
$country = $_POST['country'];
$accept = $_POST['accept'];

if ($submit)
//echo $email;
//die();
				{
					$namecheck = $handler -> prepare("SELECT username FROM reusers WHERE username='$username'");
					$namecheck -> execute();
					//$num_rows = $namecheck ->fetchColumn();

//if($num_rows =0)
if ($namecheck->rowCount() != 0)

				{
					die("Username already taken!");

		}

if ($fullname&&$username&&$password&&$repeatpassword&&$email&&$houseno&&$addressa&&$addressc&&$county&&$state&&$country)
				{
if($accept == 1)
				{
if ($password==$repeatpassword)
				{
//check char lenght of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
				{
					echo '<span style="color: red;">Lenght of username or fullname is too long</span>';
		}
	else
				{
//check password length
if(strlen($password)>25||strlen($password)<6)
				{
					echo'<span style="color: red;">Password must be between 6 and 25 characters</span>';
		}
else
				{
					//check password length
					$emailcheck = $handler ->query("SELECT Count (email) FROM reusers WHERE email='$email'");
					$count = $emailcheck ->fetchColumn();
if($count!=0)
				{
					echo'<span style="color: red;">email already registered Please sign in into your account to continue</span>';
		}
else
    			{
       				//generate random code
      				 $code = rand(11111111,99999999);

       				//send activation email
      				 $to = $email;
      				 $subject = "Activate your account";
      				 $headers = "From: donotreply@reaco.uk;
      				 $body = " Hello $fullname,\
\
Username $username,\
\
 Password $password ,\
\
You registered and need to activate your account, n\
Please keep this email safe as it contains your password . Click the link below or paste it into the URL bar of your browser\
\
http://reacheasy.co.uk/activate.php?code=$code\
\
Thanks!";



 if (!mail($to,$subject,$body,$headers))
           			echo "We couldn't sign you up at this time. Please try again later.";

else

				{
					//register the user!
					//encript password
					$password = md5($password);
					$repeatpassword = md5($repeatpassword);


					$ins = "INSERT INTO reusers ('',?,?,?,?,?,0,?,?,?,?,?,?,?)";
					$query = $handler -> prepare($ins);
					$query -> execute(array($fullname,$username,$password,$email,$code,$houseno,$addressa,$addressb,$addressc,$county,$state,$country));

die("You have been registered successfully! Please check your email ($email) to activate your account<a href='index.php'>Return to login page</a>");
}
}
}
}
}
else
	echo'<span style="color: red;">Your passwords do not match!</span>';

}
else
	echo'<span style="color: red;">Please read and accept Terms and Conditions before registering!</span>';
}
else
		echo '<span style="color: red;">Please fill in <b>all</> fields!</span>';

}
?>

So if you add a load of echo() statements for to show progress through the code, how far does it get? Blank page implies it’s failing on your if($submit) line as everything else seems to have an error message.

it does not go pass

if ($submit)
echo $email;
die();

which just shows the data are available .

i guess its the verification codes like

                    $namecheck = $handler -> prepare("SELECT username FROM reusers WHERE username='$username'"); 
                    $namecheck -> execute(); 
                    //$num_rows = $namecheck ->fetchColumn(); 

//if($num_rows =0)  
if ($namecheck->rowCount() != 0) 

                { 
                    die("Username already taken!"); 

        }

thats the problem.

i have checked it line by line and corrected some line but the insert statement is not working

if ($submit)
//echo $email;
//die();				
{
					$namecheck = $handler -> prepare("SELECT username FROM reusers WHERE username='$username'");
					$namecheck -> execute();
					//$num_rows = $namecheck ->fetchColumn();
					//echo $email;
//die();
if ($namecheck->rowCount() != 0)

				{
					die("Username already taken!");

		}
if ($fullname&&$username&&$password&&$repeatpassword&&$email&&$houseno&&$addressa&&$addressc&&$county&&$state&&$country)
				{
if($accept == 1)
				{
if ($password==$repeatpassword)
				{
//check char lenght of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
				{
					echo '<span style="color: red;">Lenght of username or fullname is too long</span>';
		}
	else
				{
//check password length
if(strlen($password)>25||strlen($password)<6)
				{
					echo'<span style="color: red;">Password must be between 6 and 25 characters</span>';
		}
else
				{
					//check password length
					
					$emailcheck = $handler ->prepare("SELECT email FROM reusers WHERE email='$email'");
					$emailcheck -> execute();
if ($emailcheck->rowCount() != 0)
				{
					echo'<span style="color: red;">email already registered Please sign in into your account to continue</span>';
		}
else
    			{
       				//generate random code
      				 $code = rand(11111111,99999999);
       
       				//send activation email
      				 $to = $email;
      				 $subject = "Activate your account";
      				 $headers = "From: donotreply@reacheasy.co.uk";
      				 $body = " Hello $fullname,\
\
Username $username,\
\
 Password $password ,\
\
You registered and need to activate your account, n\
Please keep this email safe as it contains your password . Click the link below or paste it into the URL bar of your browser\
\
http://reacheasy.co.uk/activate.php?code=$code\
\
Thanks!";

       

 if (!mail($to,$subject,$body,$headers))
           			echo "We couldn't sign you up at this time. Please try again later.";

else

				{
					//register the user!
					//encript password
					$password = md5($password);
					$repeatpassword = md5($repeatpassword);


					$ins = "INSERT INTO reusers ('',?,?,?,?,?,'0',?,?,?,?,?,?,?)";
					$query = $handler -> prepare($ins);
					$query -> execute(array($fullname,$username,$password,$email,$code,$houseno,$addressa,$addressb,$addressc,$county,$state,$country));

die("You have been registered successfully! Please check your email ($email) to activate your account<a href='index.php'>Return to login page</a>");

the table has the parameters

id
fullname
username
password
repeatpassword
email
code
active (to be set to 0)
houseno
addressa
addressb
addressc
county
state
country


// This
INSERT INTO reusers ('',?,?...
// Needs to be
INSERT INTO reusers (null,?,?

But you should be getting errors. Try adding error_reporting(E_ALL); and letting PDO throw exceptions.

tried using null, but its still not inserting

Shouldn’t that read


$ins = "INSERT INTO reusers VALUES(null,?,?,?,?,?,'0',?,?,?,?,?,?,?)";

or is the missing VALUES keyword optional?

what do you mean by the missing values

I meant the keyword VALUES before the list of values that you want to insert. Not missing values, missing VALUES just before the open-bracket, not missing in the quote above.

I might be wrong on this, learning myself.

You literally need the VALUES word in your sql. Stop what you are doing and get your code to throw errors. Assuming the insert statement is even being reached then you should be getting a nice big “invalid sql” message. Without error checking you are flying blind.

wow .wat a miss for the last 24hours. THANKS