DeeDee Posted April 13, 2011 Share Posted April 13, 2011 Hello people I am having a bit of trouble of applying the correct users to gain access to a page if they are male. For example: There are two registered users a man and a woman. The man is registered and can access another page called men's watches but not a page called women's watches and the latter applies to the opposite for women. I have written this so far, however it keeps returning the else statement even though the user is correctly logged on. <?php session_start(); $Watches = $_REQUEST['Watches']; $Female = $_SESSION['Female']; $Man = $_SESSION['Man']; if (isset($Man)) { $query = "SELECT Man, Watches FROM Male WHERE Watches = '$Watches' AND Man = '$Man'"; mysql_query($query); echo "Correct user"; <a href='watches4men.php'>Mens Watches</a> exit(); } else { echo "Not the correct user"; exit(); } ?> I hope my example is clear for you guys for your possible solutions. P.S (I have no intention of being sexist but should it offend some people I apolgise) Thank you Link to comment Share on other sites More sharing options...
Jonathon Posted April 13, 2011 Share Posted April 13, 2011 DeeDee, First try echoing out your variables I think you'll find them empty So you need to look at how to set the session variable 1 Link to comment Share on other sites More sharing options...
Jonathon Posted April 13, 2011 Share Posted April 13, 2011 Also your not echoing out your link properly 1 Link to comment Share on other sites More sharing options...
DeeDee Posted April 13, 2011 Author Share Posted April 13, 2011 DeeDee, First try echoing out your variables I think you'll find them empty So you need to look at how to set the session variable Oh no I didn't notice it I forgot to put echo there, thx I have corrected that now. BTW Jon, I have echoed out my variables but I have only managed to get the username for $Man. Link to comment Share on other sites More sharing options...
Jonathon Posted April 13, 2011 Share Posted April 13, 2011 what username variable? $Man is blank right? Is the page you posted where your setting the $_SESSION['Man']; 1 Link to comment Share on other sites More sharing options...
DeeDee Posted April 13, 2011 Author Share Posted April 13, 2011 what username variable? $Man is blank right? Is the page you posted where your setting the $_SESSION['Man']; Yes, this line is the only output being returned. $Man = $_SESSION['Man']; Link to comment Share on other sites More sharing options...
Jonathon Posted April 13, 2011 Share Posted April 13, 2011 Yes, this line is the only output being returned. $Man = $_SESSION['Man']; What does it output if you echo $Man; If its nothing as I suspect then you havent set it the $_SESSION['Man'] properly. 1 Link to comment Share on other sites More sharing options...
DeeDee Posted April 13, 2011 Author Share Posted April 13, 2011 It outputs 5489. Link to comment Share on other sites More sharing options...
Jonathon Posted April 13, 2011 Share Posted April 13, 2011 Ok so your setting $_SESSION['Man'] somewhere prior to this script. What does $_REQUEST['Watches'] return? What should it return? And how are you passing the data to this script? 1 Link to comment Share on other sites More sharing options...
DeeDee Posted April 14, 2011 Author Share Posted April 14, 2011 Ok so your setting $_SESSION['Man'] somewhere prior to this script. What does $_REQUEST['Watches'] return? What should it return? And how are you passing the data to this script? When I echo this out it returns Skoda. I think I now know where I have gone wrong here, I am attempting to pass the session data of the user into another script but requires to have a citizen watch instead of having Skoda. Ok I know what to do now Thank you Jon. Link to comment Share on other sites More sharing options...
Recommended Posts