-2

its a PDO registration script. its working fine without Gender,dob,ip. i added three new columns dob, Gender, ip. after adding these columns it shows these errors. i can't figure it out what is the problem.

signup.php

if(isset($_POST['btn-signup']))
{
    $uname = trim($_POST['txtuname']);
    $email = trim($_POST['txtemail']);
    $upass = trim($_POST['txtpass']);
    $dob = trim($_POST['dob']);
    $Gender = trim($_POST['sex']);
    $ip = $_SERVER['REMOTE_ADDR'];
    $code = md5(uniqid(rand()));

    $stmt = $reg_user->runQuery("SELECT * FROM tbl_users WHERE userEmail=:email_id");
    $stmt->execute(array(":email_id"=>$email));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);

    if($stmt->rowCount() > 0)
    {
        $msg = "
              <div class='alert alert-error'>
                <button class='close' data-dismiss='alert'>&times;</button>
                    <strong>Sorry !</strong>  email allready exists , Please Try another one
              </div>
              ";
    }

<?php if(isset($msg)) echo $msg;  ?>
      <form class="form-signin" method="post">
        <h2 class="form-signin-heading">Sign Up</h2><hr />
        <input type="text" class="input-block-level" placeholder="Username" name="txtuname" required />
        <input type="email" class="input-block-level" placeholder="Email address" name="txtemail" required />
        <input type="password" class="input-block-level" placeholder="Password" name="txtpass" required />
        <input type="date" class="input-block-level" placeholder="dob" name="dob" required />
        <input type="text" class="input-block-level" placeholder="Gender" name="sex" />
        <hr />
        <button class="btn btn-large btn-primary" type="submit" name="btn-signup">Sign Up</button>
        <a href="index.php" style="float:right;" class="btn btn-large">Sign In</a>
      </form>

class.user.php

public function register($uname,$email,$upass,$code) {
    try {                           
        $password = md5($upass);
        $stmt = $this->conn->prepare("INSERT INTO tbl_users(userName, userEmail, 
        userPass, tokenCode, Gender, dob,ip) VALUES(:user_name, :user_mail, :user_pass, :active_code, :Gender_l, :dob_l, :ip_l)");
        $stmt->bindparam(":user_name",$uname);
        $stmt->bindparam(":user_mail",$email);
        $stmt->bindparam(":user_pass",$password);
        $stmt->bindparam(":active_code",$code);
        $stmt->bindparam(":Gender_l",$Gender);
        $stmt->bindparam(":dob_l",$dob);
        $stmt->bindparam(":ip_l",$ip);
        $stmt->execute();   
        return $stmt;
    } catch(PDOException $ex) {
        echo $ex->getMessage();
    }
}

i just add 3 new columns Gebder,dob,ip. this code show this error. its working before adding these new columns.

what is the problem ?

thanks :)

Manoj Sharma
  • 1,467
  • 2
  • 13
  • 20
Utam Sharma
  • 77
  • 11

1 Answers1

0

May be You have kept Gender field in your database as not null. Either you allow null to be inserted or required Gender field.

Jaymin Panchal
  • 2,797
  • 2
  • 27
  • 31