n0TTT_ Posted May 27, 2013 at 05:45 PM Report #509240 Posted May 27, 2013 at 05:45 PM Boas tanho este code : <?php //If the user has submitted the form if($_POST['submit']){ //protect the posted value then store them to variables $username = protect($_POST['username']); $password = protect($_POST['password']); //Check if the username or password boxes were not filled in if(!$username || !$password){ //if not display an error message echo "<center>You need to fill in a <b>Username</b> and a <b>Password</b>!</center>"; }else{ //if the were continue checking //select all rows from the table where the username matches the one entered by the user $res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'"); $num = mysql_num_rows($res); //check if there was not a match if($num == 0){ //if not display an error message echo "<center>The <b>Username</b> you supplied does not exist!</center>"; }else{ //if there was a match continue checking //select all rows where the username and password match the ones submitted by the user $res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."' AND `password` = '".$password."'"); $num = mysql_num_rows($res); //check if there was not a match if($num == 0){ //if not display error message echo "<center>The <b>Password</b> you supplied does not match the one for that username!</center>"; }else{ //if there was continue checking //split all fields fom the correct row into an associative array $row = mysql_fetch_assoc($res); //check to see if the user has not activated their account yet if($row['active'] != 1){ //if not display error message echo "<center>You have not yet <b>Activated</b> your account!</center>"; }else{ //if they have log them in //set the login session storing there id - we use this to see if they are logged in or not $_SESSION['uid'] = $row['id']; //show message echo "<center>You have successfully logged in!</center>"; //update the online field to 50 seconds into the future $time = date('U')+50; mysql_query("UPDATE `users` SET `online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); //redirect them to the usersonline page header('Location: ../reg/regusersOnline.php'); } } } } } ?> <form action="../index.php" method="post"> <div id="border"> <table cellpadding="2" cellspacing="0" border="0"> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="Login" /></td> </tr> <tr> <td align="center" colspan="2"><a href="./reg/register.php">Register</a> | <a href="./reg/forgot.php">Forgot Pass</a></td> </tr> </table> </div> </form> <? ob_end_flush(); ?> e estame a dar erro no login...
HappyHippyHippo Posted May 27, 2013 at 05:58 PM Report #509241 Posted May 27, 2013 at 05:58 PM de onde tiraste esse código ? qual o erro que te dá ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
n0TTT_ Posted May 27, 2013 at 06:13 PM Author Report #509244 Posted May 27, 2013 at 06:13 PM de onde tiraste esse código ? qual o erro que te dá ? Diz que a pagina nao existe.. vai para a host.. http://www.tutorialized.com/tutorial/How-to-Build-a-Full-Featured-Login-System/63367
KTachyon Posted May 27, 2013 at 06:54 PM Report #509248 Posted May 27, 2013 at 06:54 PM É suposto fazeres submit para a própria página e não para o "../index.php". Remove a action do form. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
n0TTT_ Posted May 27, 2013 at 07:41 PM Author Report #509253 Posted May 27, 2013 at 07:41 PM (edited) É suposto fazeres submit para a própria página e não para o "../index.php". Remove a action do form. Não está a dar.. meti assim: <form method="post"> <div id="border"> <table cellpadding="2" cellspacing="0" border="0"> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="Login" /></td> </tr> <tr> <td align="center" colspan="2"><a href="./reg/register.php">Register</a> | <a href="./reg/forgot.php">Forgot Pass</a></td> </tr> </table> </div> </form> Edited May 27, 2013 at 08:14 PM by n0TTT_
NunoDinis Posted May 27, 2013 at 09:11 PM Report #509266 Posted May 27, 2013 at 09:11 PM Não está a dar.. meti assim: Dá erro ? Não faz nada ? Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
KTachyon Posted May 28, 2013 at 09:39 AM Report #509370 Posted May 28, 2013 at 09:39 AM Dá erro ? Não faz nada ? Ainda não aprendeste a utilizar a telepatia? 😄 “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
HappyHippyHippo Posted May 28, 2013 at 09:49 AM Report #509372 Posted May 28, 2013 at 09:49 AM Ainda não aprendeste a utilizar a telepatia? 😄 telepatia (para mim) só mesmo isto : https://www.youtube.com/embed/Mb92Bi4L4wQ?feature=oembed IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
NunoDinis Posted May 28, 2013 at 10:23 AM Report #509379 Posted May 28, 2013 at 10:23 AM Ainda não aprendeste a utilizar a telepatia? 😄 Era bom era 🙂 telepatia (para mim) só mesmo isto : https://www.youtube.com/embed/Mb92Bi4L4wQ?feature=oembed Subscrevo. Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now