CrownVictoriaCop Posted November 29, 2010 Share Posted November 29, 2010 I'm having trouble with a script and I just can't figure out what's wrong with it. The script is located at http://www.qlhosting.com/ham/check.php Here's the code for it <?php if (isset($_POST['submit'])) { $domain = $_POST['domain']; $password = md5($_POST['password']); include 'db.php'; mysql_query("SELECT * FROM apps WHERE domain='$domain' AND WHERE cpassmd5='$password' LIMIT 1"); $stat = $row['status']; } else { } ?> <!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=utf-8" /> <title>Quotaless Web Hosting | Check Status</title> <style type="text/css"> body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } </style> </head> <body> <h1>Check Application/Account Status</h1> <?php if ($stat="PENDING") { echo "<hr />"; echo "Your application is currently listed as PENDING. Our staff have not viewed your application yet. Please be patient, and watch your email for a response. Thank you!"; } elseif ($stat="NMI") { echo "<hr />"; echo "We need more information from you in order to take action on your application. Please check your e-mail inbox for a message from our staff specifically stating what we need. If you did not get this message, please post a message on our support forum. Thank you!"; } else { } ?> <hr /> <h2>To check the status of your application or account, login using the form below.</h2> <form id="check" name="check" method="post" action="<?php echo $PHP_SELF;?>"> <p>Domain: <input type="text" name="domain" id="domain" /> <br /> Password: <input type="password" name="password" id="password" /> <br /> <input type="submit" name="button" id="button" value="Check" /> </p> </form> <hr /> <p> </p> </body> </html> The part under if ($stat="PENDING") is performed upon page load, even when the if condition relating to it is false. I can't seem to figure out what exactly is wrong here. Please help me out. I would really appreciate the help. Thanks! Anthony Quote Link to comment https://forums.phpfreaks.com/topic/220169-if-condition-is-being-performed-when-false/ Share on other sites More sharing options...
KevinM1 Posted November 29, 2010 Share Posted November 29, 2010 = is the assignment operator. == is the equality operator. Use == for your comparison. Quote Link to comment https://forums.phpfreaks.com/topic/220169-if-condition-is-being-performed-when-false/#findComment-1141079 Share on other sites More sharing options...
CrownVictoriaCop Posted November 29, 2010 Author Share Posted November 29, 2010 Thanks, the operator fix worked. But now there's only one problem: when I enter valid data into the form, nothing happens. I changed <input type="submit" name="button" id="button" value="Check" /> to <input type="submit" name="submit" id="submit" value="Check" /> to satisfy the if condition, but still, no result. Quote Link to comment https://forums.phpfreaks.com/topic/220169-if-condition-is-being-performed-when-false/#findComment-1141092 Share on other sites More sharing options...
Pikachu2000 Posted November 29, 2010 Share Posted November 29, 2010 $stat = $row['status']; doesn't hold a value in your code, it holds a result resource. You need to get the values out of the result resource with a mysql_fetch_*() function. $query = "SELECT * FROM apps WHERE domain='$domain' AND WHERE cpassmd5='$password' LIMIT 1": $result = mysql_query($query) or die( mysql_error() ); $row = mysql_fetch_assoc($result); $stat = $row['status']; Quote Link to comment https://forums.phpfreaks.com/topic/220169-if-condition-is-being-performed-when-false/#findComment-1141096 Share on other sites More sharing options...
CrownVictoriaCop Posted November 30, 2010 Author Share Posted November 30, 2010 It works! Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/220169-if-condition-is-being-performed-when-false/#findComment-1141156 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.