-4

I'm new here so I apologize beforehand if i don't make the questions right, or give too much information (or less).

I have this problem making my login page in php: in many lines, it gives me syntax errors.

These lines are: 31, 39, 42, 43, 55, 56, 57, 62, 63, 65, 68, 71, 73, 77, 79, 80, 85, 93, 94, 95, 96, 97, 101, 103, 111, 112, 113, 114, 115, 119.

Sorry if I put so many errors, i'm learning and searched all over the web for tutorials but they didn't help me.

and here's my entire code:

<?php
$servername = "localhost";
$email="root";
$password="";
$dbname="testnew";
//create connection
$conn = new MySQLi($servername, $email, $password, $dbname);
//check the connection
if($con->connect_error){
    die("connection failed".$conn->connect_error);  
}
if(isset($_POST['email'])){
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $sql = "SELECT * FROM loginnnew WHERE email='".$email."' AND password='".$pass."' LIMIT 1;
    $result = $conn->query(sql);
    if($result->num_rows>0){
    echo 'Has iniciado sesión correctamente'
    exit();
    }else{
    echo 'Contraseña o e-mail incorrectos.';
    exit();
    }
    }
}
?>
<!DOCTYPE html>
<html >
<head>
  <title>Responsive Login/Signup Modal Window</title>
  <script src='https://s.codepen.io/assets/libs/modernizr.js' type="text/javascript"></script>
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">


      <link rel="stylesheet" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/css/style.css">
      <style type="text/css">
      body,td,th {
    color: #FFFFFF;
}
body {
    background-color: #9E1B1D;
}
      </style>
</head>

<body>
  <body>
    <header role="banner">
        <div id="cd-logo"><a href="#0"><img src="Images/HEADERIC.png" alt="Logo"></a></div>

        <nav class="main-nav">
            <ul>
                <!-- inser more links here -->
                <li><a class="cd-signin" href="#0">Inicia Sesión</a></li>
                <li><a class="cd-signup" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/registro.html">Registrarse</a></li>
            </ul>
        </nav>
    </header>

    <div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
        <div class="cd-user-modal-container"> <!-- this is the container wrapper -->
            <ul class="cd-switcher">
                <li><a href="#0">Sign in</a></li>
            </ul>

            <div id="cd-login"> <!-- log in form -->
                <form method="post" action="/paginainicio.php" class="cd-form">
                    <p class="fieldset">
                        <label class="image-replace cd-email" for="signin-email">E-mail</label>
                        <input name="email" class="full-width has-padding has-border" id="signin-email" type="email" placeholder="E-mail">
                        <span class="cd-error-message">Error message here!</span>
                    </p>

                    <p class="fieldset">
                        <label class="image-replace cd-password" for="signin-password">Contraseña</label>
                        <input name="pass" class="full-width has-padding has-border" id="signin-password" type="text"  placeholder="Contraseña">
                        <a href="#0" class="hide-password">Hide</a>
                        <span class="cd-error-message">Error message here!</span>
                    </p>

                    <p class="fieldset">
                        <input type="checkbox" id="remember-me" checked>
                        <label for="remember-me">Recordarme</label>
                    </p>

                    <p class="fieldset">
                        <input class="full-width" type="submit" value="Inicia Sesión">
                    </p>
                </form>

                <p class="cd-form-bottom-message"><a href="#0">¿Has olvidado tu contraseña?</a></p>
                <!-- <a href="#0" class="cd-close-form">Close</a> -->
            </div> <!-- cd-login -->
            <div id="cd-reset-password"> <!-- reset password form -->
                <p class="cd-form-message">¿Has olvidado tu contraseña? Ingresa tu e-mail y te enviaremos un link para recuperarla.</p>

                <form class="cd-form">
                    <p class="fieldset">
                        <label class="image-replace cd-email" for="reset-email">E-mail</label>
                        <input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail">
                        <span class="cd-error-message">Error message here!</span>
                    </p>

                    <p class="fieldset">
                        <input class="full-width has-padding" type="submit" value="Reset password">
                    </p>
                </form>

                <p class="cd-form-bottom-message"><a href="#0">Volver al Login</a></p>
            </div> <!-- cd-reset-password -->
          <a href="#0" class="cd-close-form">Cerrar</a>
      </div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
</body>
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

    <script  src="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/js/index.js"></script>
     <img src="Images/separator50px.png" alt=""/>
      <img src="Images/separator50px.png" alt=""/>
    <center><img src="Images/LOGO.png" alt=""/></center>
     <img src="Images/separator50px.png" alt=""/>
    <center><img src="Images/fraseinicial.png" alt=""/></center>
     <img src="Images/separator50px.png" alt=""/>
      <img src="Images/separator50px.png" alt=""/>
</body>
</html>

Hope somebody can help. Thanks in advance!

Al.G.
  • 4,327
  • 6
  • 31
  • 56
  • 2
    Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Obsidian Age Oct 03 '17 at 21:48
  • Your `$sql` is missing the closing `"`. – Obsidian Age Oct 03 '17 at 21:49
  • colour codeine in SO shows the error position, get any half decent IDE and it will point theses out to to you. –  Oct 03 '17 at 21:52
  • Use an IDE, such as netbeans, phpstorm, etc. They will give good hints for syntax errors, eg, highlighting them. – Andrew Oct 03 '17 at 21:53
  • 1
    and ... SQL injection warning, this code will get you hacked –  Oct 03 '17 at 21:53
  • Also, your MySQLi connection is called `$conn`, yet you are checking for a connection error in `$con`. – Obsidian Age Oct 03 '17 at 22:05

1 Answers1

0

I can't see what your SQL connection looks like, but I did see that you forgot to end the String for your $sql variable. Try this.

Also, next time, clean up your code. There were spelling errors, missing semicolons, and all kinds of stuff.

<?php
$servername = "localhost";
$email="root";
$password="";
$dbname="testnew";
//create connection
$conn = new mysqli($servername, $email, $password, $dbname);
//check the connection
if($conn->connect_error){
 die("connection failed(".$conn->connect_error.")"); 
}
if(isset($_POST['email'])){
 $email = $_POST['email'];
 $pass = $_POST['pass'];
 $sql = "SELECT * FROM loginnnew WHERE email='".$email."' AND password='".$pass."' LIMIT 1";
 $result = $conn->query(sql);
 if($result->num_rows>0){
 echo 'Has iniciado sesión correctamente';
 exit();
 }else{
 echo 'Contraseña o e-mail incorrectos.';
 exit();
 }
 }
}
?>
<!DOCTYPE html>
<html >
<head>
  <title>Responsive Login/Signup Modal Window</title>
  <script src='https://s.codepen.io/assets/libs/modernizr.js' type="text/javascript"></script>
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">

  
      <link rel="stylesheet" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/css/style.css">
      <style type="text/css">
      body,td,th {
 color: #FFFFFF;
}
body {
 background-color: #9E1B1D;
}
      </style>
</head>

<body>
  <body>
 <header role="banner">
  <div id="cd-logo"><a href="#0"><img src="Images/HEADERIC.png" alt="Logo"></a></div>

  <nav class="main-nav">
   <ul>
    <!-- inser more links here -->
    <li><a class="cd-signin" href="#0">Inicia Sesión</a></li>
    <li><a class="cd-signup" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/registro.html">Registrarse</a></li>
   </ul>
  </nav>
 </header>

 <div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
  <div class="cd-user-modal-container"> <!-- this is the container wrapper -->
   <ul class="cd-switcher">
    <li><a href="#0">Sign in</a></li>
   </ul>

   <div id="cd-login"> <!-- log in form -->
    <form method="post" action="/paginainicio.php" class="cd-form">
     <p class="fieldset">
      <label class="image-replace cd-email" for="signin-email">E-mail</label>
      <input name="email" class="full-width has-padding has-border" id="signin-email" type="email" placeholder="E-mail">
      <span class="cd-error-message">Error message here!</span>
     </p>

     <p class="fieldset">
      <label class="image-replace cd-password" for="signin-password">Contraseña</label>
      <input name="pass" class="full-width has-padding has-border" id="signin-password" type="text"  placeholder="Contraseña">
      <a href="#0" class="hide-password">Hide</a>
      <span class="cd-error-message">Error message here!</span>
     </p>

     <p class="fieldset">
      <input type="checkbox" id="remember-me" checked>
      <label for="remember-me">Recordarme</label>
     </p>

     <p class="fieldset">
      <input class="full-width" type="submit" value="Inicia Sesión">
     </p>
    </form>
    
    <p class="cd-form-bottom-message"><a href="#0">¿Has olvidado tu contraseña?</a></p>
    <!-- <a href="#0" class="cd-close-form">Close</a> -->
   </div> <!-- cd-login -->
   <div id="cd-reset-password"> <!-- reset password form -->
    <p class="cd-form-message">¿Has olvidado tu contraseña? Ingresa tu e-mail y te enviaremos un link para recuperarla.</p>

    <form class="cd-form">
     <p class="fieldset">
      <label class="image-replace cd-email" for="reset-email">E-mail</label>
      <input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail">
      <span class="cd-error-message">Error message here!</span>
     </p>

     <p class="fieldset">
      <input class="full-width has-padding" type="submit" value="Reset password">
     </p>
    </form>

    <p class="cd-form-bottom-message"><a href="#0">Volver al Login</a></p>
   </div> <!-- cd-reset-password -->
    <a href="#0" class="cd-close-form">Cerrar</a>
   </div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
</body>
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

    <script  src="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/js/index.js"></script>
     <img src="Images/separator50px.png" alt=""/>
      <img src="Images/separator50px.png" alt=""/>
 <center><img src="Images/LOGO.png" alt=""/></center>
  <img src="Images/separator50px.png" alt=""/>
 <center><img src="Images/fraseinicial.png" alt=""/></center>
  <img src="Images/separator50px.png" alt=""/>
   <img src="Images/separator50px.png" alt=""/>
</body>
</html>
David Culbreth
  • 2,610
  • 16
  • 26