For some reason, the page doesn't load as I wrote intentionally the wrong password (to bring up the sentence refusing to log in.) I'm going to upload this as a txt file for privacy.
What's it not doing that you want it to do? Is if ($_POST['pass'] != $info['password']){ die('Incorrect password, please try again.'); } PHP: not working correctly?
It's doing confusing things: I have 2 login/passwords but after trying to login the user's login (not the administrator's) it shows the statement above with one (user's) login. I know actually why it's doing this: because I put this: if(!$_POST['username'] | !$_POST['pass']){ echo $sql; echo "You did not fill in a required field.<br />"; login(); //die('You did not fill in a required field.<br />'); } PHP: login(); It was like this before: if(!$_POST['username'] | !$_POST['pass']){ die('You did not fill in a required field.<br />'); } PHP: But then if it was unsuccessful to log in. It would show the You did not fill in a required field. But the rest of the page wouldn't load. It still doesn't load.
This is actually an include file. The HTML form is in the index page: <?php // action=" echo $_SERVER['PHP_SELF']; "?> <form name="login" method="post" onSubmit="adminLogin(); userLogin();" target="_self"> PHP: The 2 functions do do anything (they're empty) but I left it there for now. Is it important to include the action? Since it's loging to the index page.
Ok I tested by changing the method from post to get and I got a result. There are two usernames and 2 passwords which one of them is the correct answer while the other one is blank. The reason for that is that I have one login for the average user and the other one is for the administrator. What do you recommend in this occasion? Should I combine the login somehow or leave it as 2 logins or what?
To make things simpler I took the tutorial: http://php.about.com/od/finishedphp1/ss/php_login_code_2.htm again. The same error is occurring. After the die in the login page the hello doesn't appear(when I type in the wrong username. This means whatever code is underneath it will not print): if ($check2 == 0) { login(); die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>'); echo "hello!!!!"; } PHP: login page: index.php <?php ob_start(); include("dbconnection.php"); function login(){ ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td><input type="text" name="username" maxlength="40"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="50"></td></tr> <tr><td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td></tr> </table> </form> <?php } ?> <!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" /> <title>Login</title> </head> <body> <?php // Connects to your Database //mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); //mysql_select_db("Database_Name") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM ".$dbTable." WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: members.php"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM ".$dbTable." WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { login(); die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>'); echo "hello!!!!"; } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: members.php"); } } } else { // if they are not logged in login(); } ?> </body> </html> PHP: logout.php <?php ob_start(); include("dbconnection.php"); ?> <!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" /> <title>Logout</title> </head> <body> <?php $past = time() - 100; //this makes the time in the past to destroy the cookie setcookie(ID_my_site, gone, $past); setcookie(Key_my_site, gone, $past); header("Location: index.php"); ?> </body> </html> PHP: members.php <?php include("dbconnection.php"); ?> <!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" /> <title>Members Page</title> </head> <body> <?php // Connects to your Database //mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); //mysql_select_db("Database_Name") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM ".$dbTable." WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //otherwise they are shown the admin area else { echo "Admin Area<p>"; echo "Your Content<p>"; echo "<a href=logout.php>Logout</a>"; } } } else //if the cookie does not exist, they are taken to the login screen { header("Location: login.php"); } ?> </body> </html> PHP: register.php <?php include("dbconnection.php"); ?> <!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" /> <title>Register</title> </head> <body> <?php // Connects to your Database //mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); //mysql_select_db("Database_Name") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die('You did not complete all of the required fields'); } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM ".$dbTable." WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO ".$dbTable." (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you, you have registered - you may now login</a>.</p> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="60"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="10"> </td></tr> <tr><td>Confirm Password:</td><td> <input type="password" name="pass2" maxlength="10"> </td></tr> <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table> </form> <?php } ?> </body> </html> PHP:
Ok I was wondering why if I typed in the wrong username or password the die(""); would cause the code to stop printing whatever was left. So instead I used print(""); and the problem is solved. Now I wonder if I really need two (one for the administrator and the other for the average user) to login or just one because in the string, since it's in one <form> it's showing 2 usernames and 2 passwords and it's giving an error.
To try to solve the double username and password I put 1 username and 1 password and a checkbox to determine whether it's a user or the admin. But I don't understand how the members page is going to pick up the checked or unchecked?
The problem above is dealt with by adding a checkbox of whether the one who logs in is the user or administrator. But I'm still have logging problems. It keeps logging out when I click on the url and entering. login page: index.php <?php ob_start(); include("dbconnection.php"); ?> <div style="float: left; width: 100%; margin: 0px 0px 0px 0px; background-color: #7C7C7C; border: 1px solid #A5A498; border-width: 1px 1px 0px 1px;"> <span style="float: left; padding: 2px 10px 0px 12px; color: #FFFFFF; font-family: arial; font-weight:bold; font-size: 13px;">Login</span> </div> <div style="float: left; width: 100%; height: 120px; background-color: #B4B3A9; border: 1px solid #A5A498; margin: 0px 0px 0px 0px; overflow-x: hidden; overflow-y: auto;"> <?php function login(){ ?> <table border="0"> <tr> <td>Administrator:</td><td><input type="checkbox" id="adminid" name="admin" style="float: left; border: 1px solid #7C7C7C; background-color: #7C7C7C;" value="no" onClick="if(this.value=='no'){this.value='yes'; document.getElementById('register').style.display = 'none';} else{this.value='no';document.getElementById('register').style.display = 'block';};" /></td> </tr> <tr> <td>Username:</td> <td><input type="text" name="<?php //vb_login_username?>username" id="username" style="float: left; border: 1px solid #7C7C7C; font: 9px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 100px; height: 15px;" value="User Name" onBlur="if (this.value == '') this.value = 'User Name';" onFocus="if (this.value == 'User Name') this.value = '';" /></td> </tr> <tr> <td>Password:</td><td><input type="password" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 100px; height: 15px;" <?php //name="pass"?> name="<?php //vb_login_username?>pass" id="pass" /></td></tr> <tr> <td><a id="register" href="login/register.php" style="float: left; display: block; background-color: #7C7C7C; text-align: left; padding: 0px 0px 0px 5px; width: 80px; height: 20px; text-decoration: none; color: #ffffff; border: 1px solid #7C7C7C; font-weight: bold;" onMouseOver="this.style.backgroundColor='#B4B3A9'" onMouseOut="this.style.backgroundColor='#7C7C7C'">Register</a></td><td align="right"><input type="submit" style="float: left; border: 1px solid #7C7C7C; background-color: #7C7C7C; color: #ffffff; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-weight: bold; width: 100px; height: 20px;" name="submit" onMouseOver="this.style.backgroundColor='#B4B3A9'" onMouseOut="this.style.backgroundColor='#7C7C7C'" value="Login" /></td> </tr> </table> <?php } //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])){ //if there is, it logs you in and directs you to the members page $myusername = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $admin = $_COOKIE['Admin_my_site']; $user = $_COOKIE['User_my_site']; $sql = "SELECT * FROM "; if($admin=="yes"){ $sql .= $dbTable2; }else{ $sql .= $dbTable; } $sql .= " WHERE username = '".mysql_real_escape_string($myusername)."'"; $check = mysql_query($sql)or die(mysql_error()); while($info = mysql_fetch_array( $check )){ if ($pass != $info['password']){ }else{ //print("Welcome ".$myusername."! <br />Visit your <a href=\"login/member.php\">member's stat</a> <br /><a href=\"login/logout.php\">Logout</a>"); //header("Location: login/member.php"); //header("Location: "); } } } //if the login form is submitted if (isset($_POST['submit'])){ // if form has been submitted if(!$_POST['username'] | !$_POST['pass']) {// makes sure they filled it in //die('You did not fill in a required field.'); print('You did not fill in a required field.'); }// checks it against the database if (!get_magic_quotes_gpc()){ $_POST['email'] = addslashes($_POST['email']); } $sql = "SELECT * FROM "; if($admin=="yes"){ $sql .= $dbTable2; }else{ $sql .= $dbTable; } $sql .= " WHERE username = '".$_POST['username']."'"; $check = mysql_query($sql)or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { //die('That user does not exist in our database. <a href=login/register.php>Click Here to Register</a>'); print('That user does not exist in our database.'); login(); } while($info = mysql_fetch_array( $check )){ $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']){ //die('Incorrect password, please try again.'); print('Incorrect password, please try again.'); login(); }else{ // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); if($_POST["admin"]=="yes"){ setcookie(Admin_my_site, $_POST['admin'], $hour); print("<span style=\"float: left; text-align: left; padding: 5px 5px 5px 5px;\">Welcome ".$myusername."! <br />Visit your <a style=\"text-decoration: none;\" onmouseover=\"this.style.textDecoration='underline';\" onmouseout=\"this.style.textDecoration='none';\" href=\"login/member.php\">member's stat</a> <br /><a style=\"text-decoration: none;\" href=\"login/logout.php\" onmouseover=\"this.style.textDecoration='underline';\" onmouseout=\"this.style.textDecoration='none';\" >Logout</a></span>"); }else{ setcookie(User_my_site, $_POST['admin'], $hour); print("<span style=\"float: left; text-align: left; padding: 5px 5px 5px 5px;\">Welcome <span id=\"myusername\">".$myusername."</span>! <br />Visit your <a style=\"text-decoration: none;\" href=\"login/member.php\" onmouseover=\"this.style.textDecoration='underline';\" onmouseout=\"this.style.textDecoration='none';\" >member's stat</a> <br /><a style=\"text-decoration: none;\" href=\"login/logout.php\" onmouseover=\"this.style.textDecoration='underline';\" onmouseout=\"this.style.textDecoration='none';\" >Logout</a></span>"); } //then redirect them to the members area //header("Location: login/member.php"); //print("Welcome".$username); //header("Location: login/member.php"); //header("Location: "); } } }else{ // if they are not logged in login(); } ?> </div> PHP: logout.php <?php ob_start(); include("dbconnection.php"); ?> <!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" /> <title>Logout</title> </head> <body> <?php $past = time() - 100; //this makes the time in the past to destroy the cookie setcookie(ID_my_site, gone, $past); setcookie(Key_my_site, gone, $past); setcookie(Admin_my_site, gone, $past); header("Location: ../index.php"); ?> </body> </html> PHP: member.php <?php ob_start(); include("dbconnection.php"); ?> <!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" /> <title>Members Page</title> </head> <body bgcolor="#505050" text="#000000" link="#363636" vlink="#363636" alink="#d5ae83"> <div id="master" style="width: 1240px; height: 780px; margin: 0px auto; overflow: hidden; text-align: center;"> <div id="logo" style="float: left; margin: 0px; border: none; background-color: #ECECEC; width: 100%; height: 120px; padding: 0px 5px 0px 0px;"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="655" height="120" id="wheelofgod2" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flashclips/wheelofgod2.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ECECEC" /> <embed src="../../flashclips/wheelofgod2.swf" quality="high" bgcolor="#ECECEC" width="655" height="120" name="wheelofgod" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </div> <div id="leftbar" style="float: left; width: 200px; height: 1200px; margin: 5px 0px 0px 0px; background-color: #505050;"> <?php //$Colors = Array("FF0000", "0000FF", "009900", "FF9900", "660099", "00FFFF"); include("../../getFiles/links.php"); ?> </div> <div id="main" style="float: left; margin: 5px 5px 5px 5px; background-color: #D2C5A0; border: 1px solid #B5A26F; width: 810px; height: 640px; padding: 5px 5px 5px 5px; overflow-y: auto;"> <?php //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])){ $myusername = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $admin = $_COOKIE['Admin_my_site']; $user = $_COOKIE['User_my_site']; $sql = "SELECT * FROM "; if($admin=="yes"){ $sql .= $dbTable2; }else{ $sql .= $dbTable; } $sql .= " WHERE username = '".mysql_real_escape_string($myusername)."'"; //echo $sql; $check = mysql_query($sql)or die(mysql_error()); while($info = mysql_fetch_array( $check )){//if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']){ header("Location: ../index.php"); }else{//otherwise they are shown the admin area ?> <div style="float: left; width: 100%; margin: 5px 0px 0px 0px; background: #7C7C7C; border: 1px solid #A5A498; border-width: 1px 1px 0px 1px;"> <span style="float: left; padding: 2px 10px 0px 12px; color: #FFFFFF; font-family: arial; font-weight:bold; font-style: italic; font-size: 13px"><?php echo mysql_real_escape_string(strtoupper($myusername)); ?>'s Member Stat.</span> </div> <?php include("memberStat.php"); echo "<a href=\"logout.php\">Logout</a>"; } } }else{//if the cookie does not exist, they are taken to the login screen header("Location: ../index.php"); } ?> </div> <div id="rightbar" style="float: left; width: 200px; height: 1200px; margin: 5px 0px 0px 5px; background-color: #505050;"> <?php include("index.php"); //include("../../getFiles/whattodo.php"); include("../../getFiles/updates.php"); include("../../getFiles/posts.php"); ?> </div> </div> </body> </html> PHP: register.php <?php include("dbconnection.php"); ?> <!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" /> <title>Register</title> </head> <body bgcolor="#505050" text="#000000" link="#363636" vlink="#363636" alink="#d5ae83"> <div id="master" style="width: 1240px; height: 780px; margin: 0px auto; overflow: hidden; text-align: center;"> <div id="logo" style="float: left; margin: 0px; border: none; background-color: #ECECEC; width: 100%; height: 120px; padding: 0px 5px 0px 0px;"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="655" height="120" id="wheelofgod2" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flashclips/wheelofgod2.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ECECEC" /> <embed src="../../flashclips/wheelofgod2.swf" quality="high" bgcolor="#ECECEC" width="655" height="120" name="wheelofgod" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </div> <div id="leftbar" style="float: left; width: 200px; height: 1200px; margin: 5px 0px 0px 0px; background-color: #505050;"> <?php //$Colors = Array("FF0000", "0000FF", "009900", "FF9900", "660099", "00FFFF"); include("../../getFiles/links.php"); include("../../getFiles/updates.php");?> </div> <div id="main" style="float: left; margin: 5px 5px 5px 5px; background-color: #D2C5A0; border: 1px solid #B5A26F; width: 810px; height: 640px; padding: 5px 5px 5px 5px; overflow-y: auto;"> <?php //This code runs if the form has been submitted if (isset($_POST['submit'])){//This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2']){ //die('You did not complete all of the required fields'); print('You did not complete all of the required fields'); } // checks if the username is in use if (!get_magic_quotes_gpc()){ $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM ".$dbTable." WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { //die('Sorry, the username '.$_POST['username'].' is already in use.'); print('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { //die('Your passwords did not match. '); print('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO ".$dbTable." ( ...// ... )"; //echo $insert; //$add_member = mysql_query($insert); ?> <div style="float: left; width: 100%; margin: 5px 0px 0px 0px; background: #7C7C7C; border: 1px solid #A5A498; border-width: 1px 1px 0px 1px;"> <span style="float: left; padding: 2px 10px 0px 12px; color: #FFFFFF; font-family: arial; font-weight:bold; font-size: 13px">Registered</span> </div> <p>Thank you <?php echo "<span style=\"font-weight: bold; font-style: italic;\">".$_POST['username']."</span>"; ?>, you have registered - you may now <a href="../index.php">login</a>.</p> <?php }else{ ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table border="0"> <tr><td>*Username:</td><td><input type="text" name="username" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" maxlength="60" /></td></tr> <tr><td>*Password (10 characters):</td><td><input type="password" name="pass" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" maxlength="10" /></td></tr> <tr><td>*Confirm Password (10 characters):</td><td><input type="password" name="pass2" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" maxlength="10" /></td></tr> <tr> <td>*First Name:</td> <td><input name="fname" size="29" maxlength="30" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" /></td> </tr> <tr> <td>*Last Name:</td> <td><input name="lname" size="29" maxlength="40" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" /></td> </tr> <tr> <td>*Your e-mail:</td> <td><input name="email" size="29" maxlength="40" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" /></td> </tr> <tr> <td>Your URL:</td> <td><input name="url" size="29" maxlength="100" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" /></td> </tr> <tr> <td>Additional URL:</td> <td><input name="addnlurl" size="29" maxlength="100" style="float: left; border: 1px solid #7C7C7C; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; width: 200px; height: 15px;" /></td> </tr> <tr> <td> <input type="submit" style="float: left; border: 1px solid #7C7C7C; background-color: #7C7C7C; color: #ffffff; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-weight: bold; width: 200px; height: 20px; margin: 5px 5px 5px 5px;" onMouseOver="this.style.backgroundColor='#B4B3A9'" onMouseOut="this.style.backgroundColor='#7C7C7C'" name="submit" value="Register" /> </td> <td> <input type="reset" style="float: left; border: 1px solid #7C7C7C; background-color: #7C7C7C; color: #ffffff; font: 9pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-weight: bold; width: 200px; height: 20px; margin: 5px 5px 5px 5px;" onMouseOver="this.style.backgroundColor='#B4B3A9'" onMouseOut="this.style.backgroundColor='#7C7C7C'" value="Reset" name="reset" /> </td> </tr> </table> </form> <?php } ?> </div> <div id="rightbar" style="float: left; width: 200px; height: 1200px; margin: 5px 0px 0px 5px; background-color: #505050;"> <?php include("index.php"); //include("../../getFiles/whattodo.php"); include("../../getFiles/posts.php"); ?> </div> </div> </div> </body> </html> PHP:
You are using the | which means (inclusive or) in PHP bitwise functions instead of || which simply means OR. Go through all your logic IF statements and correct them, change all the | to || OR to the actual word OR unless you actually meant to do bitwise calculations.
I'll change them if I have to but just to let you know I got that from this tutorial: http://php.about.com/od/finishedphp1/ss/php_login_code_2.htm What do you mean by inclusize?
http://php.net/manual/en/language.operators.bitwise.php VS http://php.net/manual/en/language.operators.logical.php
Ok I changed them. login/index.php if(!$_POST['username'] || !$_POST['pass']) {// makes sure they filled it in PHP: register.php repeated twice if (!$_POST['username'] || !$_POST['pass'] || !$_POST['pass2']){ PHP: But it's still giving the same problem. That is on the first attempt to log in it doesn't show the $myusername next to "welcome". if(isset($_COOKIE['ID_my_site'])){ //if there is, it logs you in and directs you to the members page $myusername = $_COOKIE['ID_my_site']; PHP: But on the 2nd attempt $myusername shows. And the 2nd problem is when I click on the url address bar and enter it logs out.