Steve Angelis Posted February 5, 2008 Share Posted February 5, 2008 <?PHP $username=$_POST['username']; $activate=$_POST['activate']; require('../inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); $query = "SELECT * FROM nxg_tempmbr WHERE username='$username'"; $result = mysql_query($query) or die("$query does not make any sence;<br>" . mysql_error()); $name_exists = mysql_num_rows($result); echo $result['activate']."1"; echo $activate; if ($name_exists == 0) { echo "No such user exists."; } else { if ($activate == $result['activate']) { echo "Correct Code!"; } else { echo "Incorrect activation code."; } } ?> The code is rather simple right now. Check the username, if its it there then it gets the code and checks to see if the code is valid. It gets past the username part no problem, that works fine, checked if it passes or fails it works. It echos the variables from the previous form no problem, it checks against the database no problem, but when i try to echo or match up with from the database mainly the activate code it doesn't work and the spelling is all correct. Any ideas? Quote Link to comment Share on other sites More sharing options...
Stooney Posted February 5, 2008 Share Posted February 5, 2008 For $result['activate'] to work, u need to do $result=mysql_fetch_assoc($result); I believe. So try: $result=mysql_fetch_assoc($result); echo $result['activate']."1"; Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 5, 2008 Author Share Posted February 5, 2008 I have done that before, and I just tried it with array also, no luck. Quote Link to comment Share on other sites More sharing options...
Stooney Posted February 5, 2008 Share Posted February 5, 2008 Try this <?php $username=$_POST['username']; $activate=$_POST['activate']; require('../inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); $result=mysql_query("SELECT activate FROM nxg_tempmbr WHERE username='$username'") or die("$query does not make any sence;<br>" . mysql_error()); if (mysql_num_rows($result)==0){ echo "No such user exists."; } else{ $result=mysql_fetch_array($result); if ($activate == $result[0]){ echo "Correct Code!"; } else{ echo 'ERROR--Does '.$result[0].' = '.$activate.'?<br>'; } } ?> Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 5, 2008 Author Share Posted February 5, 2008 Ok that works lol thanx Quote Link to comment 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.