My page is not loading right
I have been on this for hours on end. When I get one thing working something else doesn't work. Well now my page is not loading to the one it is suppose to. It is loading to the content page and not the form page.I have the home page in for the users to enter in there username and passowrd and if they dont have one then they can register on the form. I put all the forms on there. I don't know what I am doing wrong. Like I said I been working on this for hours. Can someone help me thanks. Its not loading to the form it skips right over it to the content page. So if you click on register to the form you wont see it. It will go to the content page. Here are my codes This one is form page..
<?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> </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>
This is the signin form:
<?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>
and this is the home:
<!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> </td>
<td><input type="submit" name="submit" value="Log in now!" class="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
You have a misplaced semicolon in your 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']=="");
so you need to replace it with opening curly bracket.
精彩评论