...

View Full Version : Need help with Form Selections



Nakid
03-21-2009, 08:12 AM
First off, I'm relatively new to PHP.

I run a gaming clan that plays Team Fortress 2, and I've been trying to make a form to input information for the upcoming match (Opponent, Map Name, Date, Time, Connect Command). I want to output this onto a page that the user sees.

This is the code I've got currently:


<form action="" method="post">
<div align='center'>
<table width="437" border="1">
<tr>
<td name='map' rowspan="4" width="300" height="300"><?php

$mapname = $_POST['mapname'];

if ($mapname=="cp_badlands") {
echo "Map Image";
} elseif ($mapname=="cp_dustbowl"){
echo "Map Image";
} elseif ($mapname=="cp_fastlane"){
echo "Map Image";
} elseif ($mapname=="cp_freight"){
echo "Map Image";
} elseif ($mapname=="cp_granary"){
echo "Map Image";
} elseif ($mapname=="cp_gravelpit"){
echo "Map Image";
} elseif ($mapname=="cp_science"){
echo "Map Image";
} elseif ($mapname=="cp_steel"){
echo "Map Image";
} elseif ($mapname=="cp_well"){
echo "Map Image";
} elseif ($mapname=="ctf_2fort"){
echo "Map Image";
} elseif ($mapname=="ctf_turbine"){
echo "Map Image";
} elseif ($mapname=="ctf_well"){
echo "Map Image";
} elseif ($mapname=="pl_badwater"){
echo "Map Image";
} elseif ($mapname=="pl_dustbowl"){
echo "Map Image";
} elseif ($mapname=="pl_goldrush"){
echo "Map Image";
} elseif ($mapname=="pl_swift"){
echo "Map Image";
} else {
echo "No Map Image";
}
?></td>
<td width="115" name='opponent'>Opponent:
<input name="opponent" type="text" value="" size="15" /></td>
</tr>
<tr>
<td name='mapnamecell'>Map Name:
<select name="mapname">
<option value="cp_badlands">cp_badlands</option>
<option value="cp_dustbowl">cp_dustbowl</option>
<option value="cp_fastlane">cp_fastlane</option>
<option value="cp_freight">cp_freight</option>
<option value="cp_granary">cp_granary</option>
<option value="cp_gravelpit">cp_gravelpit</option>
<option value="cp_science">cp_science</option>
<option value="cp_steel">cp_steel</option>
<option value="cp_well">cp_well</option>
<option value="ctf_2fort">ctf_2fort</option>
<option value="ctf_turbine">ctf_turbine</option>
<option value="ctf_well">ctf_well</option>
<option value="pl_badwater">pl_badwater</option>
<option value="pl_dustbowl">pl_dustbowl</option>
<option value="pl_goldrush">pl_goldrush</option>
<option value="pl_swift">pl_swift</option>
</select>
</td>
</tr>
<tr>
<td name='date'>Date</td>
</tr>
<tr>
<td name='time'>Time</td>
</tr>
<tr>
<td name='connect'colspan="2">IP:
<input name="ip" type="text" size="22"/>
Password:
<input name ="joinpw" type="text" size="10" /></td>
</tr>
</table>
</div>
</form>

As you can see from the near the top, I'm trying to output the value from the dropdown box to display an image, which represents that map.

I've got 2 problems with this, I don't know how to display an image through PHP, and I don't know exactly how to say the if statement to make this happen.

Some other information I may need help with:
When the form is eventually output to the user on another page, I want the input from IP and JoinPW to combine into "connect ".$ip.";password ".$joinpw.""
I also have some other things that I'm willing to try later down the track, but I'll get this error-free first.

abduraooft
03-21-2009, 08:57 AM
if ($mapname="pl_dustbowl") should be

if ($mapname=="pl_dustbowl")

Nakid
03-21-2009, 10:10 AM
Thanks.

I still need to find out how to put an image in with PHP though, if anyone could help, that would be great.

I updated the code in the OP, correcting the error and also adding the rest of the maps to the list.

EDIT: Nevermind about the image bit, all sorted now



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum