我正在设计一个网站,养蜂人可以在网站上注册商店详细信息,在他们将信息注册到数据库后,他们会登录,然后重定向到帐户管理页面,他们可以根据需要更改详细信息。
我遇到一个问题,在用户输入详细信息之后,网站被定向到注册脚本,该脚本将用户及其详细信息添加到数据库,然后将它们带到登录脚本以通过进入刚刚添加的数据库。然而,它只是卡在registerlogin脚本上(但仍然添加了新用户)。它会添加它们,但之后不会记录它们。
我让他们能够通过登录页面登录,登录成功后会将他们引导到帐户管理页面,我在registerlogin脚本中使用了登录脚本中的类似代码。
有谁能看到我做错了什么?
注册页面(用户方):
pub_or_priv
注册脚本(服务器端):
adapter
registerlogin脚本(服务器端):
<?php
session_start();
?>
<html>
<head>
<title>Beekeeper</title>
<meta name="author" content="Nigel Kennington">
<meta name="description" content="Find local honey near you">
<meta name="keywords" content="honey, bees, bee, local">
<link href="bees.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="linkbar">
<table height="140px" ID="Table1">
<tr>
<td valign="bottom"><a href="index.html">Home</a> |</td>
<td valign="bottom"><a href="about.html">About</a> |</td>
<td valign="bottom"><a href="contact.html">Contact</a></td>
</tr>
</table>
</div>
<div id="bulk">
<table width="100%" border="0" cellpadding="0" cellspacing="0" ID="Table1">
<tr id="spacer">
<td class="leftnav" align="right" valign="top" nowrap width="120px">
<h5>Find Honey from:</h5>
<p><a href="#">Highlands and Islands</a></p>
<p><a href="#">North Eastern Scotland</a></p>
<p><a href="#">Eastern Scotland</a></p>
<p><a href="#">South Western Scotland</a>
<h5>List your produce:</h5>
<p><a href="keeperlogin.php">Keepers Page</a></p>
<p>Register</p>
</td>
<td>
<p class="first">To get a free account and start advertising your produce here, fill in the information below:</p>
<p>If you already have an account, you can login by clicking on the "Keepers Page" link on the left hand side.</p>
<fieldset>
<?php
$fullUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($fullUrl, "signup=empty") == true)
{
echo "<p class='error' >You did not fill in all fields,
please check you have filled all fields out!</p>";
//exit();
}
elseif (strpos($fullUrl, "signup=passwordnotmatch") == true)
{
echo "<p class='error'>Passwords entered do not match!</p>";
//exit();
}
elseif (strpos($fullUrl, "signup=bothnumbersnotentered") == true)
{
echo "<p class='error'>You must enter at least one phone number!</p>";
//exit();
}
elseif (strpos($fullUrl, "signup=usertaken") == true)
{
echo "<p class='error'>User is already on the system!</p>";
//exit();
}
elseif (strpos($fullUrl, "signup=success") == true)
{
echo "<p class='success'>You have been signed up!</p>";
//exit();
}
?>
<form method="POST" action="register.php">
<table border=0 id="flush">
<tr>
<td width="50"></td>
<td colspan="2"><div class="heading">About You</div></td>
</tr>
<tr>
<td width="50"></td>
<td>Your Name:</td>
<td><input type="text" name="keepername" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Password:</td>
<td><input type="password" name="password" size="16"></td>
</tr>
<tr>
<td width="50"></td>
<td>Re-enter Password:</td>
<td><input type="password" name="password2" size="16"></td>
</tr>
<tr>
<td width="50"></td>
<td>Your E-mail:</td>
<td><input type="text" name="accountemail" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td colspan="2"><div class="heading">About your produce</div></td>
</tr>
<tr>
<td width="50"></td>
<td>Shop Name:</td>
<td><input type="text" name="shopname" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Area:</td>
<td>
<input type="radio" name="area" value="HaI"> Highlands and Islands<br>
<input type="radio" name="area" value="NES"> North Eastern Scotland<br>
<input type="radio" name="area" value="ES"> Eastern Scotland<br>
<input type="radio" name="area" value="SWS"> South Western Scotland
</td>
</tr>
<tr>
<td width="50"></td>
<td>Address:</td>
<td><textarea rows="2" name="address" cols="27"></textarea></td>
</tr>
<tr>
<td width="50"></td>
<td>Town/City:</td>
<td><input type="text" name="town" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Postcode:</td>
<td><input type="text" name="postcode" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Phone Number:</td>
<td><input type="text" name="landline" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Mobile Number:</td>
<td><input type="text" name="mobile" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Shop E-mail:</td>
<td><input type="text" name="shopemail" size="32"></td>
</tr>
<tr>
<td width="50"></td>
<td>Describe your produce:</td>
<td><textarea rows="4" name="description" cols="27"></textarea></td>
</tr>
<tr>
<td width="50"></td>
<td></td>
<td><input type="submit" name="submit" value="Register"></td>
</tr>
</table>
</fieldset>
</form>
</td>
<td valign="top" align="right">
<img src="gfx/register.jpg" alt="honey pots" class="imgborder">
</td>
</tr>
</table>
</div>
<div id="footer">
© 2008 beekeeper.com | <A href="privacy.html">Privacy Policy</A> |
<A href="terms.html">Terms of Use</A>
</div>
</body>
答案 0 :(得分:0)
注册成功后,您不会在registerlogin.php中根据需要传递$_POST
值。而不是$_POST
而是最好使用$_SESSION
。以下更改。
在register.php中:
就在上面:
header("Location: registerlogin.php?");
添加强>
$_SESSION['keeper_name'] = $name;
在registerlogin.php中:
替换:
isset($_POST['submit'])
使用:
isset($_SESSION['keeper_name']) AND $_SESSION['keeper_name'] != ""
<强>替换强>
$name = mysqli_real_escape_string($_POST['keepername']);
。通过强>
$name = mysqli_real_escape_string($_SESSION['keeper_name']);