Reading Submitted POST Strings

If you are looking for a code sample to reuse as a reader of form submissions, then this code is not complete. You will need to consider other things. One, for example, is that you don’t know whether the user is running several instances of the same script at the same time and jumping between them; this is covered in a different post.

Initialization of the read POST variables on the receiving end of a POST submission is the focus of this blog post. In the following example the variables $tag and $state need to be (and are being) initialized so that there will be no PHP parser errors saying that a POST variable is being used without having been initialized.

// Initialize $tag and $state.
if ( isset($_POST['submit']) AND (($_POST['submit'] == "Edit vehicle data")
   OR ($_POST['submit'] == "Retrieve vehicle data")) ) {

  // Initialize $tag and $state.
  if ( isset($_POST['tag']) ) {
    $tag = $_POST['tag'];
  } else {
    $tag = "";
  if ( isset($_POST['state']) ) {
    $state = $_POST['state'];
  } else {
    $state = "";

About samehramzylabib

See About on
This entry was posted in Coding, PHP Form Processing and tagged , , , . Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s