| | |
Dreamweaver php form validation and redirect
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 110
Reputation:
Solved Threads: 1
I post this solution to a form validation and redirect as an addition to a comment page written with dreamweaver. Unfortunately Dreamweaver does not provide server-side validation for php. You're expected to purchase an extension.
My problem
I have a comments page with a comment form. I wanted the comment input to a database if ok but if a user tried to input code or a link, I wanted to redirect them back to the form page without their comment input to the database. I also needed to work out where in the Dreamweaver written code to place my validation and redirect.
My problem
I have a comments page with a comment form. I wanted the comment input to a database if ok but if a user tried to input code or a link, I wanted to redirect them back to the form page without their comment input to the database. I also needed to work out where in the Dreamweaver written code to place my validation and redirect.
PHP Syntax (Toggle Plain Text)
Here it is, I hope it helps somebody else. $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "comments")) { $comment = htmlentities($_POST['comment']); function check_field1($comment) { if (preg_match("/</", $comment)) { return TRUE; } } $error=0; if(check_field1($comment)) { $error++; $insertGoTo = "comments.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); // $error=$error+1; } if($error == 0) $insertSQL = sprintf("INSERT INTO comments (comment, `day`, `month`, `year`) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['comment'], "text"), GetSQLValueString($_POST['day'], "int"), GetSQLValueString($_POST['month'], "text"), GetSQLValueString($_POST['year'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); $insertGoTo = "comments.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); }
•
•
Join Date: Jul 2007
Posts: 110
Reputation:
Solved Threads: 1
•
•
•
•
hi
Is this echoing out properly, or do you just need help with the javascript validation ?
I'm not actually asking for help here, I've posted this as a solution to the problem I posed here and in other posts. The above code works successfully. I could extend it with error messages and reproduction of the original comment to be edited but I decided to put a warning on the comments page not to post links or code, or the comment would be deleted.
Re javascript, I already have js client-side validation with error messages. Thank you anyway for your interest in this thread.
Taffd
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
I am not sure if I am having a simoilar problem or it just sounds smilir to a new bie. I have acreated a form, www.lifespringnaz.com/form/lifegroup.html
I have redirected it to a "thank you " at www.lifespringnaz.com/form/confirm.html. Yet, I do not get the confirmation page and I can't figure it out. Also, In Explorer, when i hit th e the submit button I get a message "am I sure I want to send this from my email address"? and it changes the subject line. Is this something that can be eliminated? Thanks!
I have redirected it to a "thank you " at www.lifespringnaz.com/form/confirm.html. Yet, I do not get the confirmation page and I can't figure it out. Also, In Explorer, when i hit th e the submit button I get a message "am I sure I want to send this from my email address"? and it changes the subject line. Is this something that can be eliminated? Thanks!
What is the problem actually ? Because the OP wasn't asking for any help !
•
•
•
•
Hi Designer,
I'm not actually asking for help here, I've posted this as a solution to the problem I posed here and in other posts. The above code works successfully.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
What is the problem actually ? Because the OP wasn't asking for any help !
There are two problems:
Problem 1:
I have created a form, you can view it at: www.lifespringnaz.com/form/lifegroup.html
I want to redirected it to a "thank you " at www.lifespringnaz.com/form/confirm.html.
What code would I use here? And where do I put it?
Problem 2:
When filling out the form in Explorer, after I hit the the submit button I get a message "am I sure I want to send this from my email address"? ...it brings up the person’s email application and creates a message then you hit send. Is that going to work with everyone’s email apps? What if they just used web-based email?
I would like to eliminate those extra boxes, is there a way to have it generate that email il message internally without having the additional step of launching the email application.
Most forms I submit online like that don’t have the additional step/s after hitting submit. Lastly when the information is forwarded to me (the recipient), it seems to change the “subject” from Lifespring Report Form to “emailing . . “ So I want to eliminate the extra steps here and the changing of the subject line.
Thanks, Judi
•
•
•
•
I am not sure if you are replying to my post or another.
There are two problems:
Problem 1:
I have created a form, you can view it at: www.lifespringnaz.com/form/lifegroup.html
I want to redirected it to a "thank you " at www.lifespringnaz.com/form/confirm.html.
What code would I use here? And where do I put it?
•
•
•
•
Problem 2:
When filling out the form in Explorer, after I hit the the submit button I get a message "am I sure I want to send this from my email address"? ...it brings up the person’s email application and creates a message then you hit send. Is that going to work with everyone’s email apps? What if they just used web-based email?
I would like to eliminate those extra boxes, is there a way to have it generate that email il message internally without having the additional step of launching the email application.
Most forms I submit online like that don’t have the additional step/s after hitting submit.
•
•
•
•
Lastly when the information is forwarded to me (the recipient), it seems to change the “subject” from Lifespring Report Form to “emailing . . “ So I want to eliminate the extra steps here and the changing of the subject line.
Thanks, Judi
Cheers,
Nav
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Access hidden values by javascript
- Next Thread: Parse CSV file header
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array basics beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google head href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail menu mlm mod_rewrite multiple mysql number oop parse password paypal pdf php phpmyadmin problem query radio random recourse recursion regex remote script search seo server sessions sms soap source space sql structure syntax system table tutorial update upload url validation validator variable video web webdesign xml youtube






