I'm in the process of making a website, I know the basics of PHP etc.. and have a page where a user has to sign up and activiate thier account via e-mail, when they clikc the link it change a field in the MySQL database from 0 to 1. If it remains 0 the user cannot login in.
What I want to do, is set it up so if the password is wrong say 5 times then this activiation number is updated and changed to 0 again. How would be best to do this? If statement? While loop or what??
I have attached the work in progress of the code and any help would be appreciated ASAP!
What I want to do, is set it up so if the password is wrong say 5 times then this activiation number is updated and changed to 0 again. How would be best to do this? If statement? While loop or what??
I have attached the work in progress of the code and any help would be appreciated ASAP!
Code:
<?php
include "dbconnect.php";
session_start();
$email =$_POST["email"];
$password =$_POST["password"];
$password2 = md5("$password");
$activation = 1;
$i=0;
if ($i < 5)
{
if (empty($email) or empty($password))
{
$_SESSION["message"] = "Must enter your E-mail and Password " ;
header("Location: login.php"); //This sets the redirection information
//Ends the script and redirects to above
}
$query = "SELECT * FROM clients_details WHERE email = '$email' AND password = '$password2' AND activation = '$activation' ";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0)
{
$_SESSION["authenticatedUser"] = $email;
// Relocate to the logged-in page
header("Location: usercontrol.php");
}
else
{
$i = + 1;
$_SESSION["message"] = "Could not login as $email " ;
header("Location: login.php");
}
}
else {
$query = " UPDATE clients_details SET activation = '0' WHERE email= '$email' ";
$_SESSION["message"] = "$email your account has been blocked, please contact the systems administrator! " ;
header("Location: login.php");
}
exit;
?>
Comment