i'm doing a form submit. i've got these 2 files. 1) php html form 2) php file which receives post data from #1
the process will have to be like this: 1) user go to php html form, key in some data and click submit to post data. 2) the php file will receive the post data and proce开发者_高级运维ss it. 3) after processing the data, i would need the php file to return the post data back to the php html form and populate the textbox.
how can i do this? i understand we can normally post to PHP_SELF and process it in the same php html form but i would like to use a separate php file to receive and process post data.
Since you're using a seperate PHP file to process the post, and using redirects to get back to the original page, you'll need some way to pass the data. You've got 2 main options:
- Posting directly to the seperate processing page, and redirecting back to the form page.
- Posting via AJAX and returning the textarea data as an AJAX response
Option 1 is the easiest and quite doable, but you'd need to store the data somewhere while redirecting. Storing it in the $_SESSION array is the best bet. You could stuff it into a cookie or pass it via query argument, but both are hideoulsy bad ideas (just mentioning them for completeness).
Option 2's more involved, and you need to build some infrastructure into your page to handle the AJAX responses, page updates, and how to handle error conditions and display appropriate message ("YOu didn't fill out this field", "that's not a valid credit card", etc....), but saves you having to redirect and store the data between the requests.
it would use javascript to change object values for example:
input1.value = ``
精彩评论