Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php runs both codes :S

Featured Replies

http://membership00.heliohost.org/register.php

 

create an account on this, once its created it says 'our account was successfully created. Please click here to login.'

 

but my login box says 'Error. Sorry, your account could not be found. Please click here to try again.'

 

which is weird :S

 

as once you click the button to create the account the other script runs aswell, how can i stop this?

 

ill post code up if you need ;)

  • Author

Need to see code mate!

 

<?php
include "connect.php";
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>PHP Project</title>  
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css" type="text/css" />  
</head>  
<body link="#12A2F1" vlink="#12A2F1" alink="#12A2F1">  
<div id="wrapper">
<div id="headerleft"><h1 id="logo">PHP ? LOGIN SYSTEM<h1></div><div id="headerright"><?php  
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username']))  
{  
    ?><div id="loginarea"> 
   <p><font color='white' size='2'>Welcome: <b><?=$_SESSION['username']?></b></font></p>
   <p><font size='2'><a href="logout.php">sign out</a></font></div></p>

    <?php  
}  
elseif(!empty($_POST['username']) && !empty($_POST['password']))  
{  
   $username = mysql_real_escape_string($_POST['username']);  
   $password = md5(mysql_real_escape_string($_POST['password']));  
$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);


   $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");  

   if(mysql_num_rows($checklogin) == 1)  
   {  
       $row = mysql_fetch_array($checklogin);  
       $email = $row['email'];  
       $_SESSION['username'] = $username;  
       $_SESSION['email'] = $email;  
       $_SESSION['LoggedIn'] = 1;  
       echo "<div id='loginarea'><font color='green' size='2'>Success. </font>";  
       echo "<font color='white' size='2'>We are now redirecting you to the home page.</font></div>";  
       echo "<meta http-equiv='refresh' content='=2;index.php' />";  
   }  	
   else  
   { 
       echo "<div id='loginarea'><font color='red' size='2'>Error. </font>";  
       echo "<font color='white' size='2'>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</font></div>";  
   }  
}  
else  
{  
   ?><div id="loginarea"> <img src="1315320419_key.png" style="float:left;paddingp-top:2px;">  
   <form method="post" action="index.php" name="loginform" id="loginform">  
    <input type="text" name="username" id="username" class="labels" value="Username" size="10" />
    <input type="password" name="password" id="password" value="*********" class="labels" size="10" /> 
    <input type="submit" name="login" id="login" value="GO" class="formbutton" style="margin-left:3px;margin-top:1px;" />    
   </form><font size="2"><a href="register.php" style="margin-top:3px;">Register</a>   <a href="forgotpassword.php">Forgot Password?</a></font></div>
  <?php  
}  
?>  </div>
<div class="clear"></div>
<div id="wrap">
<div id="main">
<?php  
if(!empty($_POST['username']) && !empty($_POST['password']))  
{  
   $username = mysql_real_escape_string($_POST['username']);  
   $password = md5(mysql_real_escape_string($_POST['password']));  
   $email = mysql_real_escape_string($_POST['email']);  

    $checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'");  

    if(mysql_num_rows($checkusername) == 1)  
    {  
       echo "<h1>Error</h1>";  
       echo "<p>Sorry, that username is taken. Please go back and try again.</p>";  
    }  
    else  
    {  
       $registerquery = mysql_query("INSERT INTO users (username, password, email, firstname, lastname) VALUES('".$username."', '".$password."', '".$email."', '".$firstname."', '".$lastname."')"); 
       if($registerquery)  
       {  
           echo "<h1>Success</h1>";  
           echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>";  
       }  
       else  
       {  
           echo "<h1>Error</h1>";  
           echo "<p>Sorry, your registration failed. Please go back and try again.</p>";  
       }  
    }  
}  
else  
{  
   ?>  

  <h1>Register</h1>  

  <p>Please enter your details below to register.</p>  

   <form method="post" action="register.php" name="registerform" id="registerform">  
   <fieldset><label for="firstname">First name:</label><input type="text" name="firstname" id="firstname" /><br />  
   <label for="lastname">Last name:</label><input type="text" name="lastname" id="lastname" /><br />  	
   <label for="username">Username:</label><input type="text" name="username" id="username" /><br />  
   <label for="password">Password:</label><input type="password" name="password" id="password" /><br />  
<label for="email">Email:</label><input type="text" name="email" id="email" /><br />  
   <input type="submit" name="login" id="login" value="Login" />  
   </fieldset> </form>  

<?php
}
?>
</div><div id="sidebar"><h1 class="titles">Latest Posts</h1><br><h1 class="titles">Latest Comments</h1><br><h1 class="titles">Adverts</h1></div><div id="margin"></div></div>
<div class="clear"></div>
<div id="fotter"><p><font color="#fff" face="Tahoma, Geneva, sans-serif" size="2">© 2011-12 Company. All Rights Reserved.</p>
                <p><a href="#">Home</a> <font color="black">|</font> <a href="#">About</a> <font color="black">|</font> <a href="#">Blog</a> <font color="black">|</font> <a href="#">Contact Us</a><img src="btnsocial.png" style="margin-left:592px;"></div></div>

			<?php echo "SELECT * FROM users WHERE Username = '".$username."'";


echo "SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'";?>
</body>
</html>
</body>
</html>

  • 3 weeks later...

<?php
include "connect.php";
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>PHP Project</title>  
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css" type="text/css" />  
</head>  
<body link="#12A2F1" vlink="#12A2F1" alink="#12A2F1">  
<div id="wrapper">
<div id="headerleft"><h1 id="logo">PHP ? LOGIN SYSTEM<h1></div><div id="headerright"><?php  
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username']))  
{  
    ?><div id="loginarea"> 
   <p><font color='white' size='2'>Welcome: <b><?=$_SESSION['username']?></b></font></p>
   <p><font size='2'><a href="logout.php">sign out</a></font></div></p>

    <?php  
}  
elseif(!empty($_POST['username']) && !empty($_POST['password']))  
{  
   $username = mysql_real_escape_string($_POST['username']);  
   $password = md5(mysql_real_escape_string($_POST['password']));  
$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);


   $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");  

   if(mysql_num_rows($checklogin) == 1)  
   {  
       $row = mysql_fetch_array($checklogin);  
       $email = $row['email'];  
       $_SESSION['username'] = $username;  
       $_SESSION['email'] = $email;  
       $_SESSION['LoggedIn'] = 1;  
       echo "<div id='loginarea'><font color='green' size='2'>Success. </font>";  
       echo "<font color='white' size='2'>We are now redirecting you to the home page.</font></div>";  
       echo "<meta http-equiv='refresh' content='=2;index.php' />";  
   }  	
   else  
   { 
       echo "<div id='loginarea'><font color='red' size='2'>Error. </font>";  
       echo "<font color='white' size='2'>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</font></div>";  
   }  
}  
else  
{  
   ?><div id="loginarea"> <img src="1315320419_key.png" style="float:left;paddingp-top:2px;">  
   <form method="post" action="index.php" name="loginform" id="loginform">  
    <input type="text" name="username" id="username" class="labels" value="Username" size="10" />
    <input type="password" name="password" id="password" value="*********" class="labels" size="10" /> 
    <input type="submit" name="login" id="login" value="GO" class="formbutton" style="margin-left:3px;margin-top:1px;" />    
   </form><font size="2"><a href="register.php" style="margin-top:3px;">Register</a>   <a href="forgotpassword.php">Forgot Password?</a></font></div>
  <?php  
}  
?>  </div>
<div class="clear"></div>
<div id="wrap">
<div id="main">
<?php  
if(!empty($_POST['username']) && !empty($_POST['password']))  
{  
   $username = mysql_real_escape_string($_POST['username']);  
   $password = md5(mysql_real_escape_string($_POST['password']));  
   $email = mysql_real_escape_string($_POST['email']);  

    $checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'");  

    if(mysql_num_rows($checkusername) == 1)  
    {  
       echo "<h1>Error</h1>";  
       echo "<p>Sorry, that username is taken. Please go back and try again.</p>";  
    }  
    else  
    {  
       $registerquery = mysql_query("INSERT INTO users (username, password, email, firstname, lastname) VALUES('".$username."', '".$password."', '".$email."', '".$firstname."', '".$lastname."')"); 
       if($registerquery)  
       {  
           echo "<h1>Success</h1>";  
           echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>";  
       }  
       else  
       {  
           echo "<h1>Error</h1>";  
           echo "<p>Sorry, your registration failed. Please go back and try again.</p>";  
       }  
    }  
}  
else  
{  
   ?>  

  <h1>Register</h1>  

  <p>Please enter your details below to register.</p>  

   <form method="post" action="register.php" name="registerform" id="registerform">  
   <fieldset><label for="firstname">First name:</label><input type="text" name="firstname" id="firstname" /><br />  
   <label for="lastname">Last name:</label><input type="text" name="lastname" id="lastname" /><br />  	
   <label for="username">Username:</label><input type="text" name="username" id="username" /><br />  
   <label for="password">Password:</label><input type="password" name="password" id="password" /><br />  
<label for="email">Email:</label><input type="text" name="email" id="email" /><br />  
   <input type="submit" name="login" id="login" value="Login" />  
   </fieldset> </form>  

<?php
}
?>
</div><div id="sidebar"><h1 class="titles">Latest Posts</h1><br><h1 class="titles">Latest Comments</h1><br><h1 class="titles">Adverts</h1></div><div id="margin"></div></div>
<div class="clear"></div>
<div id="fotter"><p><font color="#fff" face="Tahoma, Geneva, sans-serif" size="2">© 2011-12 Company. All Rights Reserved.</p>
                <p><a href="#">Home</a> <font color="black">|</font> <a href="#">About</a> <font color="black">|</font> <a href="#">Blog</a> <font color="black">|</font> <a href="#">Contact Us</a><img src="btnsocial.png" style="margin-left:592px;"></div></div>

			<?php echo "SELECT * FROM users WHERE Username = '".$username."'";


echo "SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'";?>
</body>
</html>
</body>
</html>

 

put session_start at beggining of the script

 

<?php

session_start();

?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.