Jump to content
Larry Ullman's Book Forums

Recommended Posts

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

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

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

 Share

×
×
  • Create New...