Unable to execute code, displaying blank page.

$q = 'SELECT id,username,email,mobile FROM users WHERE  email=:email OR mobile=:mobile';

    $query = $dbh->prepare($q);

    $query->execute(array(':username' => $username, ':email' => $email,':mobile' => $mobile));

    if($query->rowCount() == 0){

             while($row = $query->fetch(PDO::FETCH_ASSOC)){
            if($row[2]  == $email) {
                if($row[3]  == $mobile) {
                    echo 'Mobile Number and  Email are already registered with us.';
                }

                echo 'Email is already registered with us';
            }

            echo 'Mobile Number is already registered with us';
        }
       }     
    else{ $q = 'INSERT INTO users(username,password,url,name,email,address,mobile,ip,dob) VALUES(:username,:password,:url,:name,:email,:address,:mobile,:ip,:dob)';

    $query = $dbh->prepare($q);

    $query->execute(array(':username' => $username, ':password' => $password, ':url' => $url, ':name' => $name, ':email' => $email, ':address' => $address, ':mobile' => $mobile, ':ip' => $ip, ':dob' => $dob));

    echo 'User Registered Successfully.';
        }

Recommended Answers

Are your variables on Line 5 were given a value?

i.e

$username = $_POST["txtuname"];
Jump to Post

All 3 Replies

Are your variables on Line 5 were given a value?

i.e

$username = $_POST["txtuname"];

yes all three variables having values

$username = $_POST["user_name];
$email = $_POST["email];
$mobile = $_POST["mobile];
$username = $_POST["user_name"];
$email = $_POST["email"];
$mobile = $_POST["mobile"];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.