Retrieve Date From Form Using Get Method Script

Retrieve Date From Form Using Get Method Script is use to when you type and submit a form in the data will get to through GET method.

Demo :

User Name :
Email Address :
If you need to specific field value from GET method click at any one check box :  User Name   Email 
      

Example :

Just type a username and email both at text box and click submit button .The 'Display All Field and Its Value' output will be display on the above of form.if you need to separate the username or email value to check both or part of check box and click a submit button to see 'Display the Value of a Specific Field' output on the above of form.

Code :

Following code is use to Retrieve Date From Form Using Get Method Script code if you need to copy and use to your website.


<script>
function validate()
{
  if(document.frm.username.value=='')
  {
    alert("Please Enter Username");
    document.frm.username.focus()
    return false;
  }

  if(document.frm.email.value=='')
  {
    alert('Please Enter Email Address');
    document.frm.email.focus();
    return false;
  }

  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  var address = document.forms['frm'].elements['email'].value;
  if(reg.test(address) == false)
  {
    alert('This is invalid Email Address');
    document.frm.email.value='';
    document.frm.email.focus();
    return false;
  }
}
</script>

  <?php
  if(!isset($_GET[is_username]) && !isset($_GET[is_email]) && (count($_GET)!=0))
  {
    echo "<u>Display All Field and Its Value</u><br>";
    foreach ($_GET as $key => $value)
    {
      echo "$key = $value";
      echo "<br />";
    }
  }
?>

  <?php
  if(isset($_GET[is_username]) or isset($_GET[is_email]))
  {
    echo "<u>Display the Value of a Specific Field</u><br>";
    if(isset($_GET[is_username]) && isset($_GET[is_email]))
    {
      echo 'User Name :  '.$_GET[username]; echo "<br>";
      echo 'Email Address :  '.$_GET[email];
    }
  else if(isset($_GET[is_username]))
  {
    echo 'User Name :  '.$_GET[username];
  }
  else if(isset($_GET[is_email]))
  {
    echo 'Email Address :  '.$_GET[email];
  }
}
?>
<form id="frm" name="frm" method="get" onsubmit="return validate()">
User Name :  <input type="text" name="username" id="username" />
Email Address :   <input type="text" name="email" id="email" />
If you need to specific field value from POST method click at any one check box :   <input type="checkbox" name="is_username" id="is_username" /> User Name  <input type="checkbox" name="is_email" id="is_email"/> Email 
<input type="submit" name="submit" id="submit" value="Submit" /> 
</form>

In the above validate() function have use to empty validation and email validation of GET method.In the above form is use to pass the data to server through GET method.

Free Download Script :

If you need Retrieve Date From Form Using Get Method Script click and download from following link.

Download




Content