0

I'm trying to add this (www.dha.gov.za/status/index.php) to my page. I want a form to post to the page and then print the result on my page, with out any redirecting. The form is pretty simple:

<form action="http://www.dha.gov.za/status/index.php" method="POST">
<label>ENTER ID Number </label><br />
<INPUT NAME="id" TYPE="text" MAXLENGTH=13 SIZE=13 style="font-size:32px;" />
<INPUT TYPE=submit NAME="vstatus" VALUE="ID Application" >
<INPUT TYPE=submit NAME="vstatus" VALUE="Passport Application" >
<INPUT TYPE=submit NAME="vstatus" VALUE="Marital">
<INPUT TYPE=submit NAME="vstatus" VALUE="Alive or Deceased">
<INPUT TYPE=submit NAME="vstatus" VALUE="ID Duplicate">
<INPUT TYPE=submit NAME="vstatus" VALUE="Permit Application">
</form>

For example if I type in my ID number and click "Marital", I get redirected to a page which says "MARRIAGE STATUS = SINGLE", I want to stay on the same page as the form, and display this and all the other possible "Submit" buttons, Passport application, ID application etc.

I CANNOT see the PHP portion of the file (www.dha.gov.za/status/index.php) or its contents, I can just see the output of POSTing to it. It is this output that I want to display.

theThirdZA
  • 17
  • 7
  • If you want to modify the current page instead of loading a new one, you need JavaScript. The keyword you are looking for is "[Ajax](https://developer.mozilla.org/en-US/docs/AJAX)". It is too broad a subject to write another Ajax tutorial on Stackoverflow and there are plenty out there already. – Quentin Apr 24 '14 at 14:05
  • This will require some js (ajax). Are you/can you use a js library, like jQuery? – Steve Apr 24 '14 at 14:15
  • http://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript – zurfyx Apr 24 '14 at 14:20

1 Answers1

0

You can do something like this :

<?php 
if(isset($_POST['id'])){

// search in database
// display result e.g: "Marriage status: Single"
}
?>
<!-- display form -->
<form action="http://www.dha.gov.za/status/index.php" method="POST">
<label>ENTER ID Number </label><br />
<INPUT NAME="id" TYPE="text" MAXLENGTH=13 SIZE=13 style="font-size:32px;" value="<?php (isset($_POST['id'])?$_POST['id']:'')?>"/>
<INPUT TYPE=submit NAME="vstatus" VALUE="ID Application" >
<INPUT TYPE=submit NAME="vstatus" VALUE="Passport Application" >
<INPUT TYPE=submit NAME="vstatus" VALUE="Marital">
<INPUT TYPE=submit NAME="vstatus" VALUE="Alive or Deceased">
<INPUT TYPE=submit NAME="vstatus" VALUE="ID Duplicate">
<INPUT TYPE=submit NAME="vstatus" VALUE="Permit Application">
</form>

with this solution you display the data and the form fill with the provided id

ekans
  • 1,662
  • 14
  • 25