herghost Posted September 25, 2009 Share Posted September 25, 2009 Hi all, I have confused myself and would like another pair of eyes to look over this: <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="Description" content="" /> <meta name="Keywords" content="" /> <meta name="Robots" content="index,follow" /> <link rel="stylesheet" href="../images/CoolWater.css" type="text/css" /> <title>Project</title> </head> <body> <div id="wrap"> <?php include('../include/header.php'); include ('../include/auth.inc.php'); include ('../include/dbconnect.php');?> <!-- content-wrap starts here --> <div id="content-wrap"> <div id="main"> <?php if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { $query = 'SELECT userlevel, credits FROM users_info u JOIN users_credits i ON u.user_id = i.user_id WHERE username = "' . mysql_real_escape_string($_SESSION['username'], $conn) . '"'; $result = mysql_query($query, $conn) or die(mysql_error($conn)); $row = mysql_fetch_array($result); extract($row); mysql_free_result($result); if ($credits <> 0) { ?> <h1>Welcome to the Question Forum.</h1> <p> <h3>Post New Topic</h3></p> <form enctype="multipart/form-data" action="forum/add_post.php" method="POST" name="postquestion"> <p> <label>Category</label> <label> <input type="radio" name="cat" value="Hardware" id="Hardware" /> Hardware</label> <label> <input type="radio" name="cat" value="Software" id="Software" /> Software</label> <label> <input type="radio" name="cat" value="Peripheral" id="Peripheral" /> Peripheral</label> <br /> <label>Operating System</label> <input name="os" type="text" id="os" /> <label>MB of RAM</label> <input name="ram" type="text" id="ram" /> <label>Type & Size of Harddrive</label> <input name="harddrive" type="text" id="harddrive" /> <label>Graphics Card</label> <input name="graphics" type="text" id="graphics" /> <label>Post Title</label> <input name="title" type="text" id="title" /> <label>Your Problem Details</label> <textarea rows="20" cols="5" name="detail" id="detail"></textarea> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label>Please upload your DXDIAG as a txt file (.txt)</label> <input name="userfile" id="userfile" type="file" /><br /> <input name="upload" type="submit" class="button" id="upload" value=" Upload "> </p> </form> </div> <?php } } else { ?> <center> <img src="images/oops.jpg" width="305" height="179" alt="oops" /> <?php echo "<p>"; echo "<h3>"; echo "To post a question you need to have at least one posting credit available, you can purchase posting credits "; echo "<a href='../users/buycredits.php'>By Clicking Here</a>"; echo "</h3>"; echo "</p>"; echo "</center>"; } ?> </div> <?php if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { include('../include/sidebar_1.php'); } else { include('../include/sidebar_0.php'); } ?> <!-- content-wrap ends here --> <?php include('../include/footer.php');?> <!-- wrap ends here --> </div> </body> </html> Ok there are 3 scenarios 1, User is logged in and has more than 0 Credits = Displays Form - Works 2, User is not logged in - Displays login message - Half works - Displays login message & Oops picture 3, User is logged in but has no credits - Display Oops Picture - Does not work - Displays Nothing i have if'd and else'd myself to crazyness and I can no longer logically work it out! Anyone give me a hand? Quote Link to comment Share on other sites More sharing options...
bothwell Posted September 25, 2009 Share Posted September 25, 2009 if ($credits <> 0) Should be: if ($credits != 0) or: if ($credits > 0) The '<>' not-equal-to syntax is for MySQL, rather than PHP Quote Link to comment Share on other sites More sharing options...
herghost Posted September 25, 2009 Author Share Posted September 25, 2009 Thanks, After a lot more trying, finally got it working! <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="Description" content="" /> <meta name="Keywords" content="" /> <meta name="Robots" content="index,follow" /> <link rel="stylesheet" href="images/CoolWater.css" type="text/css" /> <title>Project</title> </head> <body> <div id="wrap"> <?php include('include/header.php'); include ('include/dbconnect.php');?> <!-- content-wrap starts here --> <div id="content-wrap"> <div id="main"> <!--If user is not logged in--> <?php if (!isset($_SESSION['logged'])) { ?> <center><img src="images/oops.jpg" alt="oops" /><br /> <p><h3>You need to login before you can start posting</h3></p> </div> <?php include('include/sidebar_0.php'); include('include/footer.php'); echo "</body></html>"; } else { $query = 'SELECT userlevel, credits FROM users_info u JOIN users_credits i ON u.user_id = i.user_id WHERE username = "' . mysql_real_escape_string($_SESSION['username'], $conn) . '"'; $result = mysql_query($query, $conn) or die(mysql_error($conn)); $row = mysql_fetch_array($result); extract($row); mysql_free_result($result); } if ($credits > 0) { ?> <h1>Welcome to the Question Forum.</h1> <p> <h3>Post New Topic</h3></p> <form enctype="multipart/form-data" action="forum/forum/add_post.php" method="POST" name="postquestion"> <p> <label>Category</label> <label> <input type="radio" name="cat" value="Hardware" id="Hardware" /> Hardware</label> <label> <input type="radio" name="cat" value="Software" id="Software" /> Software</label> <label> <input type="radio" name="cat" value="Peripheral" id="Peripheral" /> Peripheral</label> <br /> <label>Operating System</label> <input name="os" type="text" id="os" /> <label>MB of RAM</label> <input name="ram" type="text" id="ram" /> <label>Type & Size of Harddrive</label> <input name="harddrive" type="text" id="harddrive" /> <label>Graphics Card</label> <input name="graphics" type="text" id="graphics" /> <label>Post Title</label> <input name="title" type="text" id="title" /> <label>Your Problem Details</label> <textarea rows="20" cols="5" name="detail" id="detail"></textarea> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label>Please upload your DXDIAG as a txt file (.txt)</label> <input name="userfile" id="userfile" type="file" /><br /> <input name="upload" type="submit" class="button" id="upload" value=" Upload "> </p> </form> </div> <?php } ?> <?php if ($credits == 0) { ?> <center> <img src="images/oops.jpg" width="305" height="179" alt="oops" /> <?php echo "<p>"; echo "<h3>"; echo "To post a question you need to have at least one posting credit available, you can purchase posting credits "; echo "<a href='../users/buycredits.php'>By Clicking Here</a>"; echo "</h3>"; echo "</p>"; echo "</center>"; } ?> </div> <?php if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { include('include/sidebar_1.php'); } else { include('include/sidebar_0.php'); } ?> <!-- content-wrap ends here --> <?php include('include/footer.php');?> <!-- wrap ends here --> </div> </body> </html> 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.