ghostcoder Posted November 19, 2009 Share Posted November 19, 2009 Jeffery, you cannot stop a php script and interact with it. Php is server side, so it will run the whole script before outputting the result to your browser. This is why you need to use a form to post the info back to the server. Use javascript and write a little function that takes your input and posts the value back to the server. You'll then run a php script to grab the posted variables and send your mail or do whatever else you want it to do. What I've done in the past is to have a form in the html with some hidden values. Like: <form method='post' name='myform' action='myscript.php'> <input type='hidden' name='mycustomfield' value='' /> </form> You can then take the variable in javascript and set that value before submitting the form. function formSubmit(form,info){ form.mycustomfield.value=info; form.submit(); } In php you grab the value of mycustomfield $_POST['mycustomfield']; Quote Link to comment https://forums.phpfreaks.com/topic/182108-solved-been-stuck-forever-passing-variables-between-php-and-javascript/page/2/#findComment-960815 Share on other sites More sharing options...
jeffery1493 Posted November 19, 2009 Author Share Posted November 19, 2009 excellent. That works better, but I already just found another work around that was similar. I just took the whole email routine and put it in another .php file, then had the <form> block call that .php instead of the original index.php. Then I set all the variables as hidden variables inside the <form> and retrieved each one in the second .php script with $_POST. IT worked!!!! Took me a bit of work because of all the nested quotations and whatnot........but I think we have a go. *****ISSUE RESOLVED***** and who says there aren't happy endings in PHP-land? Quote Link to comment https://forums.phpfreaks.com/topic/182108-solved-been-stuck-forever-passing-variables-between-php-and-javascript/page/2/#findComment-960833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.