我想把这个名字变成欢迎信息,比如“欢迎,!”是的,网上有很多文章可以为您提供编码,而不是在我的代码出现问题时。
无论如何,我的登录页面使用电子邮件和密码:
<?php
session_start();
if (isset($_POST['login']))
{
$email = mysql_real_escape_string(isset($_POST['email']) ? stripslashes($_POST['email']) : false);
$password = mysql_real_escape_string(isset($_POST['password']) ? stripslashes($_POST['password']) : false);
if ($email&&$password)
{
require "connect.php";
$query = mysql_query("SELECT * FROM register WHERE email LIKE '$email'");
$numrows = mysql_num_rows($query);
if (1 == $numrows)
{
$rows = mysql_fetch_assoc($query)
if ($email==$rows['email'] && $password==$rows['password'])
{
$_SESSION['email']=$rows['email'];
$_SESSION['name']=$rows['name'];
header("Location: profile.php");
}
else
{
echo ('<script type="text/javascript">alert("Incorrect Password");</script>');
header("Location: index.php");
}
}
else
{
echo ('<script type="text/javascript">alert("The Email Does Not Exist In Database");</script>');
header("Location: index.php");
}
}
else
{
echo ('<script type="text/javascript">alert("Please Enter An Email and/or Password");</script>');
header("Location: index.php");
}
}
exit();
?>
<form name="flogin" action="index.php" method="post">
<table width="350px">
<tr>
<td ><b>Email :</b></td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td><b>Password :</b></td>
<td><input type="password" name="password"></td>
</tr>
</table>
<div><input type="submit" class="login" value="Login" name="login"></div>
</form>
但我收到此错误Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\CashFlow\index.php on line 19
和我的个人资料.php
<?php
session_start();
require "connect.php";
if($_SESSION['name'])
{
$name = $_SESSION['name'];
$query = mysql_query("SELECT name FROM register WHERE name ='$name'");
$numrows = mysql_num_rows($query);
if(1 == $numrows)
{
while ($rows = mysql_fetch_assoc($query))
{
echo "Welcome, ".$rows['name']."!";
}
}
}
?>
但我得到了这个:
Notice: Undefined index: name in C:\xampp\htdocs\CashFlow\profile.php on line 5
我做错了什么?
答案 0 :(得分:0)
在线:
if ($email && $password) {
require "connect.php";
你永远不会关闭那个括号。
答案 1 :(得分:0)
你缺少花括号}
。
<?php
if (isset($_POST['login'])) { // you never closed this if statement
.....
......
}
} // Add these in your code.
exit();
?>