<?php
header("content-type:text/html:charset=utf-8");
include("conn.php");
if(isset($_POST[' übermittelt'])){
$user = $_POST['user'];
$pwd = $_POST['pwd'];
$sql = 'select * from name where user="'.$user .'"';
//$sql = "select * from name where user = '.$user'";
$result = mysqli_query($conn,$sql) ;
$row = mysqli_fetch_array ($result);
$cmp_pwd = $row['password'];
$quan =$row['quan'];
$xbb = 1;
$fx = 0;
if( $cmp_pwd == $pwd && $quan == $xbb){ //Vergleiche das aus der Datenbank abgerufene Passwort mit dem übermittelten Passwort
echo "<script language=javascript>alert('Anmeldung erfolgreich') ;</script>";
Header("Location:addhc1.php");
//Zur angegebenen Seite springen
}elseif($cmp_pwd1 == $pwd && $quan == $fx ) {H echo "& lt; script language = javascript & gt; warning ('Benutzername- oder Passwortfehler'); & lt;/script & gt;"; / /Seite neu laden
}
}
?>
<html>
<title& gt;Anmeldefenster</ Titel> meta http-equiv="Content-Type" content="text/html" charset="utf-8">
</head>
<form action="login1. php "Methode =" Beitrag "& gt;
Benutzername:
& lt; Eingabetyp =" Text "Name =" Benutzer " /& gt; " />
" <br/>
<input type="hidden" name="submitted" value="1" />
<input type="submit" value="登录" />
</form>
</body>
</html>
你的查询语句 少了一个单引号 你可以按照我这样写 $sql = 'select * from name where user ='.$user;
$sql = 'select * from name where user="'.$user.'"';
变量名用单引号。
PHP中,双引号里可以使用变量,你可以这么写:
$sql = “select * from name where user=\'$user\';";