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

Thread: Var on $_POST

  1. #1
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,502
    Thanks
    72
    Thanked 105 Times in 104 Posts

    Var on $_POST

    I am so lost on this, I must be missing one tiny thing. Any idea why I can't extract the class out of this? It comes out blank when I echo it or try to do an IF function with it.

    PHP Code:
     if (isset($_POST['submit'])) {

          
          
    $username $_POST['username'];
          
    $password $_POST['password'];
          
    $charname $_POST['charname'];
          
    $email $_POST['email'];
          
    $class $_POST['select_class'];
    //////////////

     
    if ($class == 'choose') {
            echo 
    'You didn\'t select a character class, please go back and select one.';
             die;
           }

    ///////////////

    <li>  <select id="select_class" onchange="do_image(this.value);">
        <
    option value="choose" selected="selected">Select Class</option>
        <
    option value="knight">Knight</option>
        <
    option value="enchantress">Enchantress</option>
        <
    option value="archer">Archer</option>
        <
    option value="thief">Thief</option>
        <
    option value="necromancer">Necromancer</option>
    </
    select>
    <
    div><img id="image_here" /></div>

    <
    script type="text/javascript">
    function 
    do_image(icon){
      if(
    icon !== "choose" && icon !== ""){
        
    document.getElementById("image_here").src "http://www.codingforums.com/images/"+icon+".png";
     }
    }
    </script> 
    Last edited by myfayt; 04-27-2014 at 02:05 AM.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,402
    Thanks
    11
    Thanked 298 Times in 297 Posts
    <select name="select_class" ...
    That's what you want.

  • Users who have thanked tracknut for this post:

    myfayt (04-27-2014)

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,502
    Thanks
    72
    Thanked 105 Times in 104 Posts
    Ahhhh I feel like an idiot! Thanks so much. Can't believe I missed that. Time for a break.
    Been a sign maker for 7 years. My business:
    American Made Signs


  •  

    Posting Permissions

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