peddel Posted August 13, 2008 Share Posted August 13, 2008 I made login script from 3 files named : - checklogin.php - login_fail.php - administratie_login.php The administratie_login.php is the main file / site where they log on with username and password field (dont mind the second table, its for making a border with company logo and such!) !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link href="layout.css" rel="stylesheet" type="text/css" /> <title>Deze pagina is enkel voor de administrator van deze website!</title> </head> <body> <form name="formulier_inlog" method="post" action="checklogin.php"> <table width="100%" height="100%" cellspacing="3" cellpadding="5"> <tr> <td class="hoofdtitel" align="center" colspan="2">Gelieve zich aan te melden vooraleer u kan doorgaan!</td> </tr> <tr> <td class="kortvak" align="right" style='width:50%'> Gebruikersnaam : <br /><br /> Paswoord : <br /><br /> </td> <td class="kortvak" align="left" style='width:50%'> <input type="text" name="myusername" id="myusername" size="25" /><br /><br /> <input type="password" name="mypassword" id="mypassword" size="25" /><br /><br /> </td> </tr> <tr> <td class="kortvak" align="center" colspan="2"> <input type="submit" name="controle" value="Meld aan!" /> </td> </tr> </table> <br /> <div align="center"><a href="index.html">>> Keer terug naar hoofdpagina.<<</a></div> <br /> <table height="100%" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> <table height="100%" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="boord1"></td> </tr> <tr> <td class="boord2"></td> </tr> <tr> <td class="boord3"></td> </tr> <tr> <td class="boord4"></td> </tr> </table> </td> <td class="fotokolom" align="right"> <img src="logo.png" alt="--LOGO IVOO--"> </td> </tr> </table> </form> </body> </html> Next i made a php scrypt that needs to be called upon when user hits submit <?php //connectie tot server en database mysql_connect("localhost","admin","admin")or die("Connection to MySQL failed. [".mysql_error()."]"); mysql_select_db("ivoo_voorontwerp")or die("Connection to database failed. [".mysql_error()."]"); //paswoord en username die ingegeven zijn opvragen $myusername = $_POST['myusername']; $mypassword = $_POST['mypassword']; $sql = "SELECT * FROM 'admin_logins' WHERE username='$myusername' and password='$mypassword'"; $result = mysql_query($sql); //tellen hoeveel rijen er de juiste combinatie hebben //indien er slechts 1 rij is dan is er een match en mag er ingelogd worden $count = mysql_num_rows($result); if($count == 1){ header("location:administratie.php"); }else{ header("location:login_fail.php"); } ?> administratie.php is the website called upon when login is succesfull if it failed u get this page : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link href="layout.css" rel="stylesheet" type="text/css" /> <title>Aanmelden website mislukt !</title> </head> <body> <table width="100%" height="100%" cellspacing="3" cellpadding="5"> <tr> <td class="hoofdtitel" align="center" colspan="2">Login mislukt! Gelieve terug te keren naar hoofdpagina !</td> </tr> <tr> <td class="kortvak" align="center" colspan="2"> <br /> <div align="center"><a href="index.html">>> Keer terug naar hoofdpagina.<<</a></div> <br /> </td> </tr> </table> <table height="100%" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> <table height="100%" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="boord1"></td> </tr> <tr> <td class="boord2"></td> </tr> <tr> <td class="boord3"></td> </tr> <tr> <td class="boord4"></td> </tr> </table> </td> <td class="fotokolom" align="right"> <img src="logo.png" alt="--LOGO IVOO--"> </td> </tr> </table> </form> </body> </html> PROBLEM = Whenever i login, even with the right username and password it redirects me to the failure page Anyone knows how ? The table inside MySQL is a table inside database ivoo_voorontwerp called admin_logins Inside table are 3 combos USERNAME PASSWORD admin lente franky lente koen lente Link to comment https://forums.phpfreaks.com/topic/119439-solved-problem-on-my-login-script/ Share on other sites More sharing options...
peddel Posted August 13, 2008 Author Share Posted August 13, 2008 found another script that made my login script work, think i misdid something on creating the database. PROBLEM SOLVED Link to comment https://forums.phpfreaks.com/topic/119439-solved-problem-on-my-login-script/#findComment-615304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.