user validation always displaying invalid ? please help


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

I have 2 accounts and there is a field in mysql called validated it can be either "true" or "false"

I tried writing a code so when the user logs in if the user is validated meaning
$username = $_POST['username'];
$validated = true
$validation = a mysql query that selects validated from members where username = $username

$validated == $validation

and I have to accounts made
1 account username is "google" its validation is set to false
2nd account username is "jaydesigns" its validation is set to true

but when I login both come up as not validated

here is the page code:

Code: <?

include_once"config.php";
$final_report = "Please complete all the fields below..";
if(isset($_POST['login'])){
$username= trim($_POST['username']);
$password = trim($_POST['password']);
if($username == NULL OR $password == NULL){
$final_report = "Please complete all the fields below..";
}else{
$check_user_data = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
if(mysql_num_rows($check_user_data) == 0){
$final_report = "This username does not exist..";
}else{
$get_user_data = mysql_fetch_array($check_user_data);
if($get_user_data['password'] == $password){

$start_idsess = $_SESSION['username'] = "".$get_user_data['username']."";
$start_passsess = $_SESSION['password'] = "".$get_user_data['password']."";
$validation = mysql_query("SELECT validated FROM `members` WHERE `username` = '$username'") or die(mysql_error());
$validated = "true";
if($validation == $validated) {

$final_report ="You are now logged in $start_idsess ";

} else {

$final_report ="Your account is not validated $start_idsess,

Please Activate your account from the email you recieved from us.


If you did not recieve an email click <a href='./activate-send.php'>here</a> to resend the email

You will be logged out Now";
session_unset('username');
session_unset('password');

}

?>
<meta http-equiv="Refresh" content="0; URL=./members.php">
<?php
}}}}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Funky Vision Membership Script</title>
</head>

<body><form action="" method="post">
<table width="312" align="center">
<tr><td colspan='2'><?php echo "$final_report" ?></td></tr><tr>
<tr>
<td width="120">Username:</td>
<td width="180"><input type="text" name="username" size="30" maxlength="25"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" size="30" maxlength="25"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="login" value="Login" /></td>
</tr>
</table>

</form>
</body>
</html>

No comments posted yet

Your Answer:

Login to answer
209 Like 12 Dislike
Previous forums Next forums
Other forums

Entering Data Problem
Code: $result = mysql_query("SELECT * FROM flights");
while ($row = mysql_fetch_array($

Getting PHP to ammended the selected in option field
Hey Guys

thanks for everyones help so far. This site and its users are oozing awesomness.

Can php detect connection speed and thereafter swap out elements?
No code to post, lads, yet. Just looking for a yay or nay at this stage:

Can a php script be

Empty text file when there is over XXXX lines of text.

define("RANDOM_FILE","/public_html/random.txt");
$randomEntry = "

Transform value 0 in no and 1 in yes help needed
Hello,
I have this in the table: "value" type int 0 to represent false and 1 to represe

Form help: Syntax & Logic
Hello again all,

I'm working on a form and ran into a wall (again) and can't seem to think th

upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi

Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.

Typedef struct vs just struct
Anyone know the rationale for using typedef for structs when a struct is itself a typedef? I have s

FPDF Help
I've been playing with the FPDF module. I was building a form and rolling right along and then sudde

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash