How To Submit Values without a Form


How To Submit Values without a Form? - PHP Script Tips - Processing Web Forms



If you know the values you want to submit, you can code the values in a hyper link at the end of the URL. The additional values provided at the end of a URL is called query string. There are two suggestions on how to use query strings to submit values to the receiving script page:

  • Code values in the same way as the form method GET as: url?name=value&name=value... This allows the receiving script to retrieve input values in the $_REQUEST array or $_GET array.
  • Code values in your own wan as: url?your_values_in_your_format. The receiving script needs to pick up the input values in $_SERVER['QUERY_STRING'].

Here is a simple script page that shows you two hyper links with query strings in different formats:

  print("<p>Please click the links below"
    ." to submit comments about</p>");
    .'<a href="/processing_forms.php?name=Guest&comment=Excellent">'
    ."It's an excellent site!</a></p>");
    .'<a href="/processing_forms.php?Visitor,Average">'
    ."It's an average site.</a></p>");

If you copy this script as submit_comments.php to your Web server, and click the first link, you will get:

Number of values: 2
  name = Guest
  comment = Excellent

If you click the second link, the current processing_forms.php will not pick up input values from $_REQUEST properly as showb below:

Number of values: 1
  Visitor,Average = 

2007-04-22, 4990👍, 0💬