Parse error in code [duplicate]

1
  

Parse error: syntax error, unexpected end of file in C: \ xampp \ htdocs \ social-networking \ login.php on line 46

<?php
    include("db.php");

    if(isset($_POST['login'])){
       $email = $_POST['email'];
       $pass = $_POST['pass'];
       $verifica = mysql_query("SELECT * FROM users WHERE email = '$email'
       If (mysql_num_rows($verifica)<=0) {
           echo '<h3>Email ou Senha Incorretos!</h3>';
       }else{
          setcookie('login',$email);
          header('location: ./');
       }

     }

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title>CloseFriend - Fazer Login</title>
    <link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
   <style type='text/css'>
   *{margin:0;padding:0;font-family: Arial;}
   body{text-align: center;}
   .logo{font-family: Lobster;color:#000000;font-size: 50px;margin:20px 0;}
   form{margin:20px 0;}
   input[type='text'],form input[type='password']{width:250px;height:40px;border:1px solid #999;padding:0 5px;border-radius:4px;margin:8px 0;font-size:17px;}
   input[type='submit']{width:260px;height:40px;border:1px solid #999;padding:0 5px;border-radius:4px;margin:8px 0;font-size:17px;color:#fff;font-weight:bold;background:#999;font-size:17px;cursor:pointer;}
   form h3{margin:20px 0;color:#999}
   form a{color:#000;text-decoration: none;}
   </style>
</head>
<body>
     <h1 class='logo'>CloseFriend</h1>
     <form method='POST'>
       <h2>Acessar sua conta</h2>
       <input type='email' placeholder='Digite seu E-mail'><br />
       <input type='password' placeholder='Senha'><br />
       <input type='submit' value=' Login'>
      </form>
      <h3>Não tem uma conta? <a href='login.php'>Criar uma conta</a></h3>
</body>
</html>
    
asked by anonymous 06.07.2017 / 14:34

2 answers

4

From:

$verifica = mysql_query("SELECT * FROM users WHERE email = '$email'

To

$verifica = mysql_query("SELECT * FROM users WHERE email = '$email'");

Solved not?

In addition, save this message within array :

echo '<h3>Email ou Senha Incorretos!</h3>';

In this way:

$error[] = '<h3>Email ou Senha Incorretos!</h3>';

Use foreach to retrieve the message, eg:

if(isset($error)) {
  foreach($error as $e) {
    echo $e;
  }
}

Note: put this foreach inside HTML .

Your input , decreased, right, I saw that you styled, inputs , text , password , but did not stylize input email

    
06.07.2017 / 14:50
3

You put the whole code inside a string and the if with the capital "I". To fix, just put "(aspas) at the end of the string you want and change If to if :

<?php
    include("db.php");

    if(isset($_POST['login'])){
       $email = $_POST['email'];
       $pass = $_POST['pass'];
       $verifica = mysql_query("SELECT * FROM users WHERE email = '$email'");
       if (mysql_num_rows($verifica)<=0) {
           echo '<h3>Email ou Senha Incorretos!</h3>';
       }else{
          setcookie('login',$email);
          header('location: ./');
       }
     }
?>

Also, I recommend using Mysqli or the PDO instead of mysql_ , since it is obsolete in newer versions of PHP.

Note also that your CSS is styling only inputs of type text and password , to fix the size of the email box, you should add it to CSS:

input[type='text'], form input[type='password'], form input[type='email'] {
    width: 250px;
    height: 40px;
    border: 1px solid #999;
    padding: 0 5px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 17px;
}
    
06.07.2017 / 14:39