Jump to content

Recommended Posts

Hi

Can anyone help me with this. I'm new to PHP. I can't get the following if/else statment to work. I think it's a syntax error but can't find it.

                                      <div class="meta">

if ($_SESSION['userchoice'] = 'order') || ($_SESSION['userchoice'] = 'book') || ($_SESSION['userchoice'] = 'drink')

{

<?include("usermap.php");?>

}

else

{

<?print $_SESSION['userchoice']?>

}

</div>

 

All I want at the moment is to include the usermap.php if the conditions are true or simply print the contents of the variable if not true. Currently it just print the code on the page but doesn't do anything.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/
Share on other sites


<div class="meta">

<?php
         if (($_SESSION['userchoice'] == 'order') || ($_SESSION['userchoice'] == 'book') || ($_SESSION['userchoice'] == 'drink'))
         {
         include("usermap.php");
         }
         else
         {   
         print $_SESSION['userchoice'];
         }

?>
         </div>

 

Yours was:

 


<div class="meta">
         if ($_SESSION['userchoice'] = 'order') || ($_SESSION['userchoice'] = 'book') || ($_SESSION['userchoice'] = 'drink')
         {
         <?include("usermap.php");?>
         }
         else
         {   
         <?print $_SESSION['userchoice']?>
         }
         </div>

 

See the difference?

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/#findComment-589491
Share on other sites

Hi Waynewex

Thanks for the help but all I'm getting now is the usemap page when I select 'drink'. I don't get it if I select 'book' or 'food'. I have four buttons on my page labelled 'drink', 'food', 'book' and 'view'. If the user select book, food or drink, I want the usemap page to be included. If they select 'view' then I just want that word to appear. Any ideas?

 

 

<?php

        if (($_SESSION['userchoice'] == 'order') || ($_SESSION['userchoice'] == 'book') || ($_SESSION['userchoice'] == 'drink'))

        {

        include("usermap.php");

        }

        else

        { 

        print $_SESSION['userchoice'];

        }

 

?>

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/#findComment-589498
Share on other sites

Hi Waynewex

Thanks for the help but all I'm getting now is the usemap page when I select 'drink'. I don't get it if I select 'book' or 'food'. I have four buttons on my page labelled 'drink', 'food', 'book' and 'view'. If the user select book, food or drink, I want the usemap page to be included. If they select 'view' then I just want that word to appear. Any ideas?

 

Could you post the buttons?

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/#findComment-589500
Share on other sites

thanks. Here's the code for my buttons

 

<form id="form1" method="post" action="userChoice.php">

<fieldset>

 

 

<BR><input id="inputsubmit1" type="submit" name="usechoice" value="food" />

<BR><input id="inputsubmit1" type="submit" name="usechoice" value="drink" />

<BR><input id="inputsubmit1" type="submit" name="usechoice" value="Book" />

<BR><input id="inputsubmit1" type="submit" name="usechoice" value="View" />

 

</fieldset>

</form>

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/#findComment-589505
Share on other sites

<form id="form1" method="post" action="userChoice.php">

              <fieldset>

             

                         

            <BR><input id="inputsubmit1" type="submit" name="usechoice" value="food" />

              <BR><input id="inputsubmit1" type="submit" name="usechoice" value="drink" />

              <BR><input id="inputsubmit1" type="submit" name="usechoice" value="book" />

              <BR><input id="inputsubmit1" type="submit" name="usechoice" value="view" />

             

              </fieldset>

            </form>

 

Try that.

Link to comment
https://forums.phpfreaks.com/topic/114645-solved-if-statement/#findComment-589513
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.