champbronc2 Posted September 22, 2008 Share Posted September 22, 2008 require('config.php'); $query24 = mysql_query("SELECT confirmed FROM users WHERE username = '$nicke'") or die(mysql_error()); $query123 = mysql_fetch_array($query24); if($query123 = 0) { echo "Activate your account via email please."; }else{ OK what I am trying to do is get the value for confirmed from the users table where the username is = $nicke ($nicke is their nickname/username) For some reason it still lets users which have a 0 in the confirmed value login. If the confirmed column is 1 or something else it means they confirmed their account. Here is the entire page. <? session_start(); if ($_POST['username']) { if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ include('header.php'); echo "<br><br>SECURITY CODE ERROR... "; include('footer.php'); exit(); } //Comprobacion del envio del nombre de usuario y password require('funciones.php'); $username=uc($_POST['username']); $password=uc($_POST['password']); if ($password==NULL) { echo "Login Incorrect. Try again."; }else{ require('config.php'); $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($query); if($data['password'] != $password) { echo "Login incorrect. Try again"; }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $row = mysql_fetch_array($query); mysql_close($con); $nicke=$row['username']; $passe=$row['password']; require('config.php'); $query24 = mysql_query("SELECT confirmed FROM users WHERE username = '$nicke'") or die(mysql_error()); $query123 = mysql_fetch_array($query24); if($query123 = 0) { echo "Activate your account via email please."; }else{ //90 dias dura la cookie setcookie("usNick",$nicke,time()+7776000); setcookie("usPass",$passe,time()+7776000); $lastlogdate = date("F j, Y - g:i a"); $lastip = getRealIP(); require('config.php'); $querybt = "UPDATE users SET lastlogdate='$lastlogdate', lastiplog='$lastip' WHERE username='$nicke'"; mysql_query($querybt) or die(mysql_error()); mysql_close($con); ?> <META HTTP-EQUIV="REFRESH" CONTENT="0;URL=members.php"> <? } } } }else{ ?> <? include('header.php'); ?> <h3>Login</h3> <br /> <a href="register.php">New User Register Free Account</a> <br> <a href="recoverpwd.php">Lost password?</a> <br><br> <div align="center"><div id="form"> <fieldset> <legend>Login</legend> <form action='login.php' method='POST'> <table width="400" border="0" align="center"> <tr> <td width="150" align="left"><p><label>Username</label></p></td> <td width="250" align="left"><input type='text' size='15' maxlength='25' name='username' autocomplete="off"value="" tabindex="1" /></td> </tr> <tr> <td width="150" align="left"><p><label>Password</label></p></td> <td width="250" align="left"><input type='password' size='15' maxlength='25' name='password' autocomplete="off" value="" tabindex="2" /></td> </tr> <tr> <td width="150" align="left"><p><label>Security Code </label></p></td> <td width="250" align="left"><input type='text' size='3' maxlength='3' name='code' autocomplete="off" class="securitycode" value="" tabindex="3" /></td> </tr> <tr> <td width="150" align="left"> </td> <td width="250" align="left"><img src="image.php?<?php echo $res; ?>" /></td> </tr> <tr> <td width="150" align="left"> </td> <td width="250" align="right"><input type="submit" value="Enter" class="submit" tabindex="4" /> </td> </tr> </table> </form> </fieldset> </div></div> <? include('footer.php'); ?> <? } ?> And then here is a SS of my database Quote Link to comment https://forums.phpfreaks.com/topic/125361-cannot-get-mysql-to-get-the-correct-value/ Share on other sites More sharing options...
.josh Posted September 22, 2008 Share Posted September 22, 2008 if($query123 = 0) { need to be if($query123 == 0) { Quote Link to comment https://forums.phpfreaks.com/topic/125361-cannot-get-mysql-to-get-the-correct-value/#findComment-648024 Share on other sites More sharing options...
.josh Posted September 22, 2008 Share Posted September 22, 2008 actually sorry, it needs to be if($query123['confirmed'] == 0) { Quote Link to comment https://forums.phpfreaks.com/topic/125361-cannot-get-mysql-to-get-the-correct-value/#findComment-648027 Share on other sites More sharing options...
champbronc2 Posted September 22, 2008 Author Share Posted September 22, 2008 Thanks. Works now! Quote Link to comment https://forums.phpfreaks.com/topic/125361-cannot-get-mysql-to-get-the-correct-value/#findComment-648037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.