0
I’m creating a system of registration on top of a system I found on the Net. In my system there are only 2 fields e-mail and password, and the password will already be pre-registered, missing so only the user fill the email. I’m having problems when I consult the database, because I can not feed this information e-mail, follow code where I doubt how to make this query.
if (!$this->db_connection->connect_errno) {
// escaping, additionally removing everything that could be (html/javascript-) code
$user_email = $this->db_connection->real_escape_string(strip_tags($_POST['user_email'], ENT_QUOTES));
$user_password = $_POST['user_password_new'];
$sql = "SELECT * FROM users WHERE user_pass = '" . $user_password . "';";
$query_check_user_password = $this->db_connection->query($sql);
if ($query_check_user_password->num_rows == 1) {
// check if user or email address already exists
$sql = "SELECT * FROM users WHERE user_email = '" . $user_email . "';";
$query_check_user_name = $this->db_connection->query($sql);
if ($query_check_user_name->num_rows == 1) {
$this->errors[] = "Sorry, that email address is already taken.";
} else {
// write new user's data into database
$sql = "INSERT INTO users (user_pass, user_email) VALUES('" . $user_password . "', '" . $user_email . "');";
$query_new_user_insert = $this->db_connection->query($sql);
// if user has been added successfully
if ($query_new_user_insert) {
$this->messages[] = "Your account has been created successfully. You can now log in.";
} else {
$this->errors[] = "Sorry, your registration failed. Please go back and try again.";
}
}
}else {
$this->errors[] = "Sorry, that password is invalid.";
}
}
When you try to record a new record it error or email value is written blank?
– rray
He gives the message "Sorry, your Registration failed. Please go back and Try Again." For Else { $this->errors[] = "Sorry, your Registration failed. Please go back and Try Again." ; }
– Breno
Leave your code like this to display the bank error message
$query_new_user_insert = $this->db_connection->query($sql) or die(mysql_error());
if using mysql_* functions, if mysqli usesmysqli_error($conexao)
– rray
A question, this is by chance a password change stream where it informs the previous password and the new password?
– Tafarel Chicotti
No, it’s not a password change flow.
– Breno