I’m a beginner with PHP and I’d like to do the following but I have not a clue of how to do this :
I have a webpage where I ask a user to submit his postal code. After he/she submits it the page redirects to another PHP page where I search in a datebase the city corresponding to the postal code. Then I write : “You’re city is …”.
What I’d like is to have this happen using only one webpage (with no visible redirection for the user). I know we can use header to redirect to the first page but I don’t know how to transmit the content (city).
It sounds like you’re looking for an AJAX post. This might sound like an advanced topic for a beginner, but if you check out a framework like jQuery (http://api.jquery.com/jQuery.post/) you’ll see it’s quite simple.
Try something like this:
In your HTML you would tag your form as myform and create an empty div with the id “result”.
Your ‘databasequery.php’ file should accept a POST variable called postcode and simply output the response you want to display on your page.