Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

Erros mysqli

$
0
0
Boa noite, eu tenho aqui este código (não foi feito por mim, so editei umas coisas) que é de registo com email activation e quando eu registo e dou submit na página aparece esses erros:

Citar

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\shizzzzzzzz\email_activation\index.php on line 17

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\shizzzzzzzz\email_activation\index.php on line 18

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\shizzzzzzzz\email_activation\index.php on line 20

Código (PHP):
<?php
include 'db.php';
$msg='';
if(!empty($_POST['email']) && isset($_POST['email']) &&  !empty($_POST['password']) &&  isset($_POST['password']) )
{
  // username and password sent from Form
  $email=mysql_real_escape_string($_POST['email']);
  $password=mysql_real_escape_string($_POST['password']);

  $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';

  if(preg_match($regex, $email))
  {  
    $password=md5($password); // Encrypted password
    $activation=md5($email.time()); // Encrypted email+timestamp

    $count=mysqli_query($connection,"SELECT uid FROM users WHERE email='$email'");
    if(mysqli_num_rows($count) < 1)
    {
      mysqli_query($connection,"INSERT INTO users(email,password,activation) VALUES('$email','$password','$activation');");

      include 'smtp/Send_Mail.php';
      $to=$email;
      $subject="Email verification";
      $body='Hi, <br/> <br/> We need to make sure you are human. Please verify your email and get started using your Website account. <br/> <br/> <a href="'.$base_url.'activation/'.$activation.'">'.$base_url.'activation/'.$activation.'</a>';
Send_Mail($to,$subject,$body);

      $msg= "Registration successful, please activate email.";

    }
    else
    {
      $msg= '<font color="#cc0000">The email is already taken, please try new.</font>';
    }
  }
  else
  {
    $msg = '<font color="#cc0000">The email you have entered is invalid, please try again.</font>';  
  }
}
?>

ajudem-me :x

Viewing all articles
Browse latest Browse all 14700