I am a little bit confused with PHP. It’s a simple question
I want to submit a form. For example:
<form name='formname' action='code.php' method="POST">
<input name='inputname' type='text'/>
<input type='submit'>
</form>
So, the server gets whatever is typed and for argument sake it adds cool to the end of the text and echos $inputname.'cool text you got there';
How do I get that response and use it in my javascript?
Your response would be in
code.phpor a page thatcode.phpredirects to.Basically, you submit the form, it loads code.php, any logic that the form inputs use go there and interact with the database, then you choose how to redirect the user from there.
If you want to see if the inputname form input is getting set, you can do this:
To get it to be used in your javascript, one potential way of doing that is adding a variable to the url:
Then, on your main page with the form (or whatever page you redirect to), you can use PHP to check to see if
$_GET['input']exists, then echo it if you like.