this is the codes I used in my login(logging.php) page..what should I do with this please?when tried to login the 1st account/other accounts..the login page is loaded but it does not redirect to any page instead, it only shows a blank page..
or if ever, my codes are wrong, can you please help me and provide a much better codes to replace this? any reply would be appreciated,thanks! 🙂 I badly needed this for a project..
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ( isset ($_POST['username']) )
{
$connect = mysql_connect("localhost","root","") or die ("could'nt connect to db");
mysql_select_db("tesda") or die ("cant connect");
$sql=("SELECT * FROM login WHERE username='$username'");
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
if($result !=0 )
{
while($row=mysql_fetch_assoc($result))
{
$username = $row['username'];
$password = $row['password'];
}
if($row['name'] == $_POST['name'])
{
if($_POST['username']=='tesda1'){
header('Location: expi1.php');
}
else if($_POST['username']=='tesda2'){
header('Location: expi2.php');
}
else if($_POST['username']=='tesda3'){
header('Location: expi3.php');
}
else if($_POST['username']=='tesda4'){
header('Location: expi4.php');
}
else if($_POST['username']=='tesda5'){
header('Location: expi5.php');
}
else if($_POST['username']=='tesda6'){
header('Location: expi6.php');
}
else if($_POST['username']=='tesda7'){
header('Location: expi7.php');
}
else if($_SESSION['username']="$dbusername"){
header('Location: attempt1.php');
}
else if($_SESSION['username']="$dbusername"){
header('Location: attempt2.php');
}
else if($_SESSION['username']="$dbusername"){
header('Location: attempt3.php');
}
}
}
}
?>
Please see if below code works out , I have made some minor changes…
Create a seprate file to handle unsuccessful attempts and show number of unsuccessfull attempts.
wrongAttempt.php
In your login page add the below line at start. I am assuming your login page is login.php.
login.php