0

Hi i have written this function to register users on my site. it was all working fine until recently the only change i have done is added extra columns into the table could this have an effect on the way i need to write this function?

function register($link){
    $username = mysqli_real_escape_string($link, $_POST['username']);
    $email = mysqli_real_escape_string($link, $_POST['email']);
    $password = mysqli_real_escape_string($link, $_POST['password']);
    $password2 = mysqli_real_escape_string($link, $_POST['password2']);
    if($password == $password2){
        $password= md5($password);
        $sql = "INSERT INTO users(UserName,email,password)VALUES('$username','$email','$password')";
        mysqli_query($link,$sql);
        $_SESSION['message'] = "You are now registered";
        $_SESSION['username'] = $username;
        header("location: index.php");
    }else{
        $_SESSION['message'] = "Passwords do not match";
    }
}
3
  • from this '$username','$email','$password' I would like you to suggest php manual before doing this . Commented Sep 10, 2016 at 16:07
  • Hi coulld you elaborate? am i doing something wrong? Commented Sep 10, 2016 at 17:19
  • 1
    look at the answer here stackoverflow.com/questions/3446216/… Commented Sep 10, 2016 at 17:25

1 Answer 1

1

It will have an effect if the columns are set-up to be NON NULL. If you aren't sure, you can check the table definition with describe in a mysql console.

Sign up to request clarification or add additional context in comments.

1 Comment

Or change the column definitions to accept null values; depending on what is appropriate for your situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.