Jump to content

If Condition Is Being Performed When False


CrownVictoriaCop

Recommended Posts

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

Link to comment
Share on other sites

$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'];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.