我是新来的,所以如果我没有提出正确的问题,或者提供过多的信息(或更少),我会事先道歉。
我有这个问题在php中创建我的登录页面:在很多行中,它给了我语法错误。
这些行是: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。
很抱歉,如果我犯了这么多错误,我会在网上学习和搜索教程,但是他们没有帮助我。
这是我的整个代码:
<?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>
希望有人可以提供帮助。提前谢谢!
答案 0 :(得分:0)
我无法看到你的SQL连接是什么样的,但我确实看到你忘了为$ sql变量结束String。试试这个。
另外,下次清理代码。有拼写错误,缺少分号和各种东西。
<?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>
&#13;