WEB form help

Discussion in 'OT Technology' started by drpepper, Jun 24, 2009.

  1. drpepper

    drpepper Active Member

    Joined:
    Nov 13, 2006
    Messages:
    38,076
    Likes Received:
    2
    Location:
    San Antonio
    I have a forum.

    I wanted to add an option field.
    the form is posting to results.php

    in results.php there is a string to show an image

    Code:
    http://xxxx.com/profile/default/spimage.php?id=<?php echo $_POST["fieldhere"]
    the field here is the form input.

    now, what i want to do is keep that the same, but add an option field to the form,

    so when an option is chosen, it changes a part of that url dynamically like so

    Code:
    http://xxxx.com/profile/[B]optionhere[/B]/spimage.php?id=<?php echo $_POST["fieldhere"]
     
  2. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    you might have to make that all onto 1 line so that the URL isn't broken.
     
  3. tryfuhl

    tryfuhl New Member

    Joined:
    Oct 4, 2003
    Messages:
    75,450
    Likes Received:
    0
    Location:
    MD/DC Metro
    can't you do something like (I don't know if this is right, I'm brand new to php)

    Code:
    $optionhere = $_GET['optionhere']
    header("Location:
    http://xxxx.com/profile/[B]$optionhere[/B]/spimage.php?id=<?php echo $_POST["fieldhere"];
    }
    
    then have the form do the GET?
    
    sorry if this is no help :hs:
     
  4. tryfuhl

    tryfuhl New Member

    Joined:
    Oct 4, 2003
    Messages:
    75,450
    Likes Received:
    0
    Location:
    MD/DC Metro
    looks like I was late and quite possibly wrong :o
     
  5. drpepper

    drpepper Active Member

    Joined:
    Nov 13, 2006
    Messages:
    38,076
    Likes Received:
    2
    Location:
    San Antonio
    hmm this looks like it could work. ill try and report back.
    thanks.
     
  6. drpepper

    drpepper Active Member

    Joined:
    Nov 13, 2006
    Messages:
    38,076
    Likes Received:
    2
    Location:
    San Antonio
    getting this error

    Parse error: syntax error, unexpected T_IF
     
  7. drpepper

    drpepper Active Member

    Joined:
    Nov 13, 2006
    Messages:
    38,076
    Likes Received:
    2
    Location:
    San Antonio
    im an idiot. it was simple. its just like passing the input field info to results.php
     
  8. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    :big grin:
     
  9. tryfuhl

    tryfuhl New Member

    Joined:
    Oct 4, 2003
    Messages:
    75,450
    Likes Received:
    0
    Location:
    MD/DC Metro
    mind posting up the fix? trying to learn :o
     
  10. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    Pretty sure my code is correct... might have been something on the form site.

    Another piece of advice is to have the form submit to the same page. You can do it like this:

    Code:
    <?php
          if (!isset($_POST['somename']))
                echo "
                      <form action='samepage.php' method='post'>
                            First Name: <input type='text' name='firstname' /><br />
                            Last Name: <input type='text' name='lastname' /><br />
                            <input type='submit' value='Go &gt;&gt;' />
                            <input type='hidden' name='somename' />
                      </form>
                ";
          else
                echo "
                Your firstname is " . $_POST['firstname'] . " and your last name is " . $_POST['lastname'] . ".
                ";
    ?>
    
    Of course i didn't do any error checking to make sure that firstname or lastname had a value, but you get the idea.
     
  11. tryfuhl

    tryfuhl New Member

    Joined:
    Oct 4, 2003
    Messages:
    75,450
    Likes Received:
    0
    Location:
    MD/DC Metro
    thanks brds
     
  12. drpepper

    drpepper Active Member

    Joined:
    Nov 13, 2006
    Messages:
    38,076
    Likes Received:
    2
    Location:
    San Antonio
    is it better to echo front end messages/text instead of just localizing php tags inside html?
     
  13. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    in this case (if/else) you would have to
     

Share This Page