我的页面加载不正确

时间:2011-07-27 02:07:10

标签: php

我已经连续几个小时了。当我得到一件事时别的东西不起作用。那么现在我的页面没有加载到它想要的那个。它正在加载到内容页面而不是表单页面。我有主页,用户输入用户名和passowrd,如果他们没有,那么他们可以在表单上注册。我把所有表格放在那里。我不知道我做错了什么。就像我说的那样我已经工作了几个小时。有人可以帮助我谢谢。 它没有加载到它跳过内容页面的形式。因此,如果您单击注册表单,您将看不到它。它将转到内容页面。 这是我的代码 这是表格页面..

<?php

function FormDisplay($strMessage="**All fields are required!"){
echo "<p><strong>".$strMessage."</strong></p>\n";
echo "<form action=\"".$PHP_SELF."\" method=\"post\">\n";
echo "<table width=\"300\" cellpadding=\"2\" cellspacing=\"2\">\n";
echo "<tr>\n";
echo "  <td><strong>Username:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"username\" value=\"". $_POST['username']."\"/> \n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>Password:</strong></td>\n";
echo "  <td><input type=\"password\" name=\"password1\" />\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td nowrap=\"nowrap\"><strong>Repeat Password:</strong></td>\n";
echo "  <td><input type=\"password\" name=\"password2\" /> \n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>First name:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"firstname\" value=\"".  $_POST['firstname']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>Last name:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"lastname\" value=\"". $_POST['lastname']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>Email:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"email\" value=\"". $_POST['email']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
 echo "<tr>\n";
echo "  <td><strong>Address:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"address\" value=\"". $_POST['address']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>City:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"city\" value=\"". $_POST['city']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>State:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"state\" value=\"". $_POST['state']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>Zip:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"zip\" value=\"". $_POST['zip']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td><strong>Phone:</strong></td>\n";
echo "  <td><input type=\"text\" name=\"phone\" value=\"". $_POST['phone']."\"/>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<tr>\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td><input type=\"submit\" name=\"submit\" value=\"Sign up now!\". class=\"submit\" />\n";
echo "</tr>\n";
echo "<tr>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
 }
 if ($_POST['submit']!=""){
if ($_POST['username']==""||$_POST['password1']==""||$_POST['password2']==""||$_POST['firstname']==""||$_POST['lastname']==""||$_POST['address']==""||$_POST['email']==""||$_POST['city']==""||$_POST['state']==""||$_POST['zip']==""||$_POST['phone']=="");
$error=1;
  }
 else if ($_POST['password1']!=$_POST['password2']){
    $error=2;
  }
 else{
$hostname="localhost";
$database="Contacts";
$mysql_login="Web_User";
$mysql_password="my1230";

if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))){
    echo "error on connect";
}
else{
if (!(mysql_select_db($database,$db))){
    echo mysql_error();
    echo "<br>error on table connection";
}
else{
    $SQL="Insert into tblUsers(username,password,firstname,lastname,email,address,city,state,zip, phone,signupDate)values)'".$_POST['username']."',PASSWORD('".$_POST['password1']."'),'".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['phone']."',NOW())";
    mysql_query($SQL);
    if (is_numeric(mysql_insert_id())){
        header("Location:member-content.php?name=".$_POST['username']);
    }
    else{
        echo "Sorry, there was an error.Please try again ot contact the administrator";
    }
    mysql_close($db);//closeing out connection,done for now
  }
   }
 }

 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <link rel="style.css" type="text/css" >
 <title>Members Only Framework::Signup page/title>
 </head>

 <body>
 <hr />
 <h2>Become a member of the coolest website on the net!</h2>
 <hr />
  <?php
  if ($error==1){
FormDisplay("You did not enter all required fields");
   }
 elseif ($error==2){
 FormDisplay("Your Passwords did not match");
  }
 else{
FormDisplay();
  }
 ?>
</body>
</html>

这是登录表格:

         <?php
include("config.php");
if ($_POST['username']==""|| $_POST['password']==""){
    header("Location:member-home.php?mode=1");
}
else{
    $hostname="localhost";
    $database="contacts";
    $mysql_login="Web_User";
    $mysql_password="my1230";

    if (!($db = mysql_connect($hostname, $mysql_login, $mysql_password))){
        echo "error on connect";
}
else{
    if (!(mysql_select_db($database,$db))){
    echo mysql_error();
    echo "<br>error on db connection";
    }
 }
 $SQL="Select username from tblusers where username='".$_POST['username']."' AND password=PASSWORD('".$_POST['password']."')";
 $resultSet=mysql_query($SQL);
 if (mysql_num_rows($resultSet)>0){
    $username=mysql_result($resultSet,0,"username");
    header("Location:member-content.php?name=".$username);
 }
 else{
    header("Location:member-home.php?mode=2");
    }
 }
 ?>
</body>
</html>

这就是家:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" type="text/css">
<title>Members Only Framework::Login Page</title>
</head>

<body>
<hr />
<h3>Welcome Members!!</h3>
<hr />
 <p><a href="member-form.php">Not a member yet? Click here to join!</a></p>
<?php
if ($_GET['mode']==1){
    echo "<p style=\"color:red;\"><strong>Please enter your username and password!</strong></p>";
 }
 else if ($_GET['mode']==2){
    echo "<p style=\"color:red;\"><strong>Sorry, there is no user with that name!</strong></p>";
}
else if ($_GET['mode']==3){
    $username=$_GET['username'];
    echo "<p style=\"color:red;\"><strong>".$username.".please login using the username and password</strong></p>";
}
?>
<p>Current members enter your username and password:</p>
<form action="member-signin.php" method="post">
<table width="200" cellpadding="2" cellspacing="2">
<tr>
    <td><strong>Username:</strong></td>
    <td><input type="text" name="username" /></td>
</tr>
<tr>
    <td><strong>Password:</strong></td>
    <td><input type="password" name="password" /></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value="Log in now!" class="submit" /></td>

</tr>
</table>
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

你的member-form.php中有一个错误的分号:

if ($_POST['username']==""||$_POST['password1']==""||$_POST['password2']==""||$_POST['firstname']==""||$_POST['lastname']==""||$_POST['address']==""||$_POST['email']==""||$_POST['city']==""||$_POST['state']==""||$_POST['zip']==""||$_POST['phone']=="");

所以你需要用开口花括号替换它。