Jump to content

[SOLVED] Clear Data after Failed Login Attempt


subter

Recommended Posts

I've tried to explain the problem to a few friends, but they don't seem to understand what I'm asking.

 

I'll try to get my problem across the best I can.

 

I've got a login form for the input of an email and password.  After the form is submitted, I pass what was submitted to a variable and check the entries against an SQL table.  If the login was a success, I redirect them to (just for example) 'loginsuccess.php', otherwise, they are redirected to 'loginfail.php'.  Now, this is where the problem begins.  After entering an incorrect email / password combination, I try to go back to the page where the form is.  Since the PHP is on the same page as the form, it seems that what was entered into the form initially is sent through the PHP again when I attempt to go back to the login page, and, as a result, I am instantly redirected back to the 'loginfail.php' page.

 

Is there any way to stop this from happening?  I am very, very new to PHP, so please, be gentle.  :P

 

Thanks in advance!

I couldn't find a way to edit my initial post, but here's the PHP:

 

<?php

include('dbconnect.inc.php');

$valid = 1;

$grabemail = $_POST['email'];
$grabpassword = md5($_POST['password']);

$grabemail = stripslashes($grabemail);
$grabemail = mysql_real_escape_string($grabemail);

$query = mysql_query("SELECT * FROM `clients` WHERE email='$grabemail' and password='$grabpassword'");
$count = mysql_num_rows($query);

if($count == 1) {

$valid = 0;

print "1";
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=loginsuccess.php">';

} if($valid == 1) {

print "2";
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=loginfail.php">';

}

?>

I've solved this issue.  I just removed the PHP from the page that the form was on, moved it to 'processlogin.php', and added action="processlogin.php" to the form.

 

I was just searching for a way to solve this while keeping the PHP on the same page as the form.

 

Thanks for the help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.