Jump to content

Recommended Posts

Hi what i want to do i use one PHP page to display a welcome page (eventually the whole website will be like this) and at the index.htm page there is the option to enter or login and if the customer just enters then it says Welcome Guest with login option, whereas if they login it welcomes them with their name and instead of login is has Previous Orders, View Basket and Logout. I know how to do this to an extent, i know it's alot of if statements anyway, i'm having a problem with sessions, when i experimented i got the Guest part to come up but not the name, and then i got the name to come up but if i tried to enter as a guest it would bring up an index error because there was no $cust variable

 

My Code

 

session_start();
$cust=$_POST['cust_no']; /*from previous login page, text field name is cust_no


if($cust == ''){
   echo "Guest <br>";
   } else {
   
   [access the database and retrieve name (variable $name)]

   echo $name ;
   }

Link to comment
https://forums.phpfreaks.com/topic/41790-session-help/
Share on other sites

I am assuming that if you enter as a user the $cust variable will be set and if you enter as a guest it wont - just thought I would point out the assumptions used in the following code

 


if (isset($cust))
{
//pull information from the database and get the name
}
else
{
echo "Guest <br>";
}

 

if you are using $_POST variables then you do not need a SESSION starting

Link to comment
https://forums.phpfreaks.com/topic/41790-session-help/#findComment-202654
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.