burkee25 Posted November 8, 2008 Share Posted November 8, 2008 Hi lads, Im wrecking my head trying to solve this code! any help would be much appreciated! So I have a html page, with an option to pick your favourite team, and then on the php page i want to show a picture of the selected team! This is from the original html page: <body> <form action="phpassign.php" method="post"> <!--Form for favourite team --> <h3>Selcet your favourite team</h3> <select name="team" id="team"> <option $team value="Mancheter United">Man Utd</option> <option value="Asrenal">Asrenal</option> <option value="Chelsea">Chelsea</option> <option value="Liverpool">Liverpool</option> </select> </body> Then I Have the PHP file: <body> <?php $team = $_GET['team']; if ( $team== "Manchester United" ) { echo "<img src=man_utd.jpg><br />"; } echo "Welcome to my homepage!"; echo $_POST['team']; echo ".<br /> "; echo $_POST['color']; ?> </body> </html> Any help would be great! Link to comment https://forums.phpfreaks.com/topic/131946-solved-if-statementvariable-help/ Share on other sites More sharing options...
pocobueno1388 Posted November 8, 2008 Share Posted November 8, 2008 You never stated your exact problem, but looking at your code you need to change this line: $team = $_GET['team']; To $team = $_POST['team']; Link to comment https://forums.phpfreaks.com/topic/131946-solved-if-statementvariable-help/#findComment-685542 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 If you use method="post" you use $_POST to read the data. This sends the data from the form to the server in packets of data. If you use method="get" you use $_GET to read the data. This sends the data from the form to the server appended onto the URL. Link to comment https://forums.phpfreaks.com/topic/131946-solved-if-statementvariable-help/#findComment-685547 Share on other sites More sharing options...
burkee25 Posted November 8, 2008 Author Share Posted November 8, 2008 Thats great thanks! tried that and it didnt work. but then somebody pointed out i'd spelled Manchester wrong once all sorted now thanks:) Link to comment https://forums.phpfreaks.com/topic/131946-solved-if-statementvariable-help/#findComment-685563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.