php codes - help needed!

4 replies
I'm not sure what this "action" is called on the net, so I'm not sure what to research about, but what I'm trying to do is how do I grab the value that the user had entered in a input field and output into a text field when they click submit?

It's hard to explain but here is an example of what I'm trying to do:
http: satellitedirect.com/affiliates.php?#sect

it's not an affiliate link. so visit it safe!

thanks for your help.

thanks
#codes #needed #php
  • Profile picture of the author Brandon Tanner
    This page sums up the process pretty well...

    PHP Tutorial - Forms
    Signature

    {{ DiscussionBoard.errors[5102862].message }}
  • Profile picture of the author jared h
    You would need to make a form that passes the variables onto another PHP script like so:

    part1.php:
    <form action="part2.php" method="post">
    <input type="text" name="this_is_a_test" value="whatever" />
    <input type="submit" value="Submit" />
    </form>

    part2.php:
    <?php
    $value = $_POST['this_is_a_test']; // Basically this is how you get the value of the input box named 'this_is_a_test'.
    // do something with the $value
    ?>
    {{ DiscussionBoard.errors[5102977].message }}
  • Profile picture of the author Iain Key
    Further to the above answers, you use $_POST variables to get any data posted by a form and $_GET variables for those posted in the url e.g. satellitedirect.com/affiliates.php?id=111

    ALWAYS sanitise your input before adding it to a database. Google "sanitise form input php" to get some ideas on that
    {{ DiscussionBoard.errors[5113113].message }}
    • Profile picture of the author MagicMonkey
      Also, if you wanted to grab all of the passed data you can use $HTTP_RAW_POST_DATA

      for example:

      $passed_data = trim($HTTP_RAW_POST_DATA);

      you can then split the data with something like:

      list($input1Val, $input2Val) = explode("," , $passed_data);
      {{ DiscussionBoard.errors[5136885].message }}

Trending Topics