Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Need help with Form Selections

    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:

    PHP Code:
    <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.
    Last edited by Nakid; 03-21-2009 at 09:09 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    if ($mapname="pl_dustbowl")
    should be
    PHP Code:
    if ($mapname=="pl_dustbowl"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Nakid (03-21-2009)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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
    Last edited by Nakid; 03-21-2009 at 10:01 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •