|
|
#1 |
|
Bronze Member
![]() Join Date: Jul 2010
Posts: 45
|
I have a form collecting data and inserting it into a mySQL table.
The processing is done by a php file. My opening form tag looks like this: <form action="php-form-processor.php" method="post"> The problem I have is, after the data is processed and entered into mySQL, I end up looking at a blank page - the mysite/php-form-processor.php page. How can I avoid displaying the page and having a small pop up reading "Data successfully stored" instead. Data validation in done in the same php file. How can I quit the script, before executing the INSERT query, in the case data validation rules are not met? Any ideas will be greatly appreciated.
|
|
|
|
|
|
#2 |
|
Gold Member
![]() Join Date: Oct 2010
Posts: 388
|
The page you are sending the data from, will contain "if else" statement, and the "php-form-processor.php" will head to the page back.
More clearly: 1. Your form page will contain "if else" statement, this will ask the question if the page loaded with "GET" variable or not. If not => show the form, else => show message. 2. When form is submitted, it goes to "php-form-processor.php" and store the inputs. When done go to "your-form-page.php?ok=1". "ok" is your "GET" variable. If there is error you can send header with "?ok=0". 3. Now we back to "your-form-page.php" with "GET" variable. So our page will show message. If "$_GET['ok']=1" post "Thank you..." if not, post "Sorry...". - Enjoy. |
|
|
|
|
|
#3 |
|
Bronze Member
![]() Join Date: Jul 2010
Posts: 45
|
Thank you Smoovo,
It is still a little murky for me. Do you know of a site that may have explanations/examples. I did not use any JavaScript processing, and the example I found (which basically works) is only using a php file for storing data in mySQL by the method "Post". That example either skipped some important data validation steps in JavaScript, or the JavaScript part is not needed in some cases. |
|
|
|
|
|
#4 |
|
New Member
![]() Join Date: Nov 2010
Posts: 6
|
|
|
|
|
|
|
#5 | |
|
Bronze Member
![]() Join Date: Jul 2010
Posts: 45
|
Quote:
Something like this: var form_field1 = document.getElementById('Form_field1').value; var form_field2 = document.getElementById('Form_field2').value; ... var url = "php-form-processor.php ?f1=" + form_field1 + "&f2="+form_field2; My form has many fields and one of them is a big text (comments) field. Thanks! |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|