PHP - If & Else

Status
Not open for further replies.

ADZ

Fully Optimized
Messages
2,231
I am going through some PHP tutorials and one thing I feel that i could benefit from is the Ifs and Elses...I have done some of the practice exams but I am looking for some help.

basically i have a page where you say your name
BOB
then you hit man or woman then next...

so i guess i need to make an if sex=man then display bla bla bla
if sex=woman then say bla bla bla

can anyone reccomend a place that I can learn that?
 
Code:
<?php
    if($sex == "Man"){
        // Display whatever it is you want
    }else if($sex == "Woman"){
         // Display the other side
    }else{
          // $sex doesn't equal man or woman, so display something else
     }
?>
Hope this helps.
 
i know the format for the statement. but what I need is for it then to go to man.php - when it goes to man.php i need it to remember valus such as OS, Shoe size...etc...

Thank you for your help though!
 
Code:
<?php

if($light == "sync"){
        echo "<p class='style1'>[b]THERE IS SYNC![/b]</p>";
		echo "<p class='style1'>Now, Can you see the user in the NOC Show callers?</p>";
		echo "<form id='NOC' name='NOC' method='post' action='realm.php'>
	  <select name='NOC'>
      <option value='yes'>Yes</option>
      <option value='no'>No</option>
      <option value='dontknow'>I dont know!</option>
    </select> 
";
	echo "<input type='submit' value='Next->' name='welcome'>";
	echo "</form>";
	if($NOC == 'yes'){
    			echo 'THEN RESET THE DARN THING';
    		}else if($NOC == 'no'){
     			echo 'uh oh';
    		}else{
     			echo 'I think it is time for you to quit!';
     }
		
    }else if($light == "nosync"){
         echo "NO SYNC!";
	}else if($light == "dead"){
         echo "THE LIGHTS ARE DEAD - SEE FUNERAL";
    }else{
          echo "If you are stuck, [url='http://www.abc']go to the KB![/url]";
     }



?>
 
You mean you need to remember values after submitting? Try useing the $_GET[] and $_POST[] variables. I would tell you all about it, but you'd get better information if you searched the internet for it, since it's been a while since I used them... :) sorry.
 
Status
Not open for further replies.
Back
Top Bottom