php codes - help needed!

by 4 replies
5
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
#programming #codes #needed #php
  • This page sums up the process pretty well...

    PHP Tutorial - Forms
  • [DELETED]
  • 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
    ?>
  • 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
    • [1] reply
    • 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);

Next Topics on Trending Feed

  • 5

    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: