SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Posting Variables

    I am trying to pass the variables: $opt and $duty from the form below to a another php form. Can anyone offer a solution on how to accomplish this task because I am still php bootstrapping.


    <form name="title_duty" method="post" action=" <?php echo $_SERVER['PHP_SELF']; ?> ">

    <?php echo $opt; ?>
    <br />

    <textarea" name="duty" rows="5" cols="40">
    <?php echo $duty; ?>
    </textarea>

    <br />
    <input type="submit" name="showduty" value="Show Duty" />

    </form>

  2. #2
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can try this
    <form name="title_duty" method="post" action=" <?php echo $_SERVER['PHP_SELF']; ?> ">
    <input type=hidden" name="option" value="<?php echo $opt; ?>"><br />
    <textarea" name="duty" rows="5" cols="40">
    <?php echo $duty; ?>
    </textarea>

    <br />
    <input type="submit" name="showduty" value="Show Duty" />
    </form>

    now i nyour php page you can acccess these variables when clicked submit like this
    PHP Code:
    $opt $_POST['option'];
    $duty $_POST['duty']; 
    so, now these variables are available in php and you create any form and the same as above form and pass these variables.

    hope this is what you want

  3. #3
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using: "post", call the variable: $_POST['opt'] if you're using: "get", call the variable: $_GET['opt']

    Plus, before you do anything meaningful with those variables, you'll need to clean them up first:
    PHP Code:
    $stringUserInput htmlspecialchars($_POST['opt']); 
    That'll strip out any nasty inject nonsense from the variable.

    Hope that helps?


Bookmarks

Posting Permissions

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