我想使用 echo 和 $_SESSION 一次使用一个 div。当我把它放到网上时,它只显示 $form。你能看看我做错了什么吗?
$signedIn ='<h3 id="throughHeader"> Account options</h3><br/>
<p id="throughP"> <a href="convenientaccountinfo.php> Account Info </a></p><br/>
<p id="throughP"><a href="convenientaddaddress.php> Add Address </a></p><br/>
<p id="throughP"> <a href="convenientaddcreditcard.php> Add C. Card </a></p><br/>
<p id="throughP"> <a href="convenientsignout.php> Sign Out </a></p>';
$form='<form id="signInForm" method="POST" action=""><h3 id="formHeader">Sign Into Account</h3><br/>
<p id="pRegister"><a id="register" href="convenientregisterpage.php"> Register </a></p><br/>
<label>Email Addr:</label><input type="text" name="userEmail" id="email" size="15"/><br/>
<label>Password:</label><input type="password" name="password" id="password" size="15"/><br/>
<input type="submit" value="Sign In" id="formSubmit" name="submit"/> </form>';
$username = $_SESSION['userEmail'];
if(!$username){
$signedInForm="$form";
}
else{
$signedInForm="$signedIn";
}
}
这是带有验证的 POST 表单,直到它设置了 $_SESSION。感谢您再次查看它。
$email=$_POST['userEmail'];
$password=$_POST['password'];
if(isset($_POST['submit'])){
if(empty($email) || empty($password)){
$msg_to_user3="Fill in both fields";
}
else{
$results=mysql_query("SELECT * FROM register WHERE userEmail='$email'");
if (mysql_num_rows($results)==0)
$msg_to_user3 ="No such User";
else
{
while ($login_row = mysql_fetch_assoc($results))
{
$password_db = $login_row['password'];
if ($password!=$password_db){
$msg_to_user3 ="Password doesn't match";
}
if ($password_db!=$password){
$msg_to_user2="<a id='forgetpassword' href='convenientforgotpassword.php'>Forget Password</a>";
}
else
{
$active = $login_row['active'];
$userEmail = $login_row['userEmail'];
if ($active==0){
$msg_to_user3= "Activate account at ($userEmail) </p>";
}
else
{
$_SESSION['userEmail']=$username;//assign session
}
}
}
}
}
}
<html>
<body>
<div id="formSignIn">
<?php echo $signedInForm ;?>
</div>
</body>
</htmo>