Get Date From Form Using Post Method Script

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

Demo :



User Name :
Email Address :
If you need to specific field value from POST 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 Post 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($_POST[is_username]) && !isset($_POST[is_email]) && (count($_POST)!=0))
  {
    echo "<u>Display All Field and Its Value</u><br>";
    foreach ($_POST as $key => $value)
    {
      echo "$key = $value";
      echo "<br />";
    }
  }
?>

  <?php
  if(isset($_POST[is_username]) or isset($_POST[is_email]))
  {
    echo "<u>Display the Value of a Specific Field</u><br>";
    if(isset($_POST[is_username]) && isset($_POST[is_email]))
    {
      echo 'User Name :  '.$_POST[username]; echo "<br>";
      echo 'Email Address :  '.$_POST[email];
    }
  else if(isset($_POST[is_username]))
  {
    echo 'User Name :  '.$_POST[username];
  }
  else if(isset($_POST[is_email]))
  {
    echo 'Email Address :  '.$_POST[email];
  }
}
?>
<form id="frm" name="frm" method="post" 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 POST method.In the above form is use to pass the data to server through POST method.

Free Download Script :

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

Download




Content