User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 363,514 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,436 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1726 | Replies: 8
Reply
Join Date: Jul 2007
Posts: 110
Reputation: Taffd is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
Taffd Taffd is offline Offline
Junior Poster

Solution Dreamweaver php form validation and redirect

  #1  
Nov 28th, 2007
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.

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));
  }
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Posts: 89
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster in Training

Re: Dreamweaver php form validation and redirect

  #2  
Nov 28th, 2007
hi
Is this echoing out properly, or do you just need help with the javascript validation ?
Reply With Quote  
Join Date: Jul 2007
Posts: 110
Reputation: Taffd is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
Taffd Taffd is offline Offline
Junior Poster

Re: Dreamweaver php form validation and redirect

  #3  
Nov 28th, 2007
Originally Posted by Designer_101 View Post
hi
Is this echoing out properly, or do you just need help with the javascript validation ?


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. 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
Reply With Quote  
Join Date: Dec 2007
Posts: 2
Reputation: judiglidden is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
judiglidden judiglidden is offline Offline
Newbie Poster

Re: Dreamweaver php form validation and redirect

  #4  
Dec 18th, 2007
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!
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,888
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 208
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: Dreamweaver php form validation and redirect

  #5  
Dec 18th, 2007
Yep.. Can you show us the code ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2006
Posts: 173
Reputation: vssp is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
vssp vssp is offline Offline
Junior Poster

Re: Dreamweaver php form validation and redirect

  #6  
Dec 19th, 2007
i have also need the solution
Last edited by vssp : Dec 19th, 2007 at 1:54 am.
Thanks
VSSP
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,888
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 208
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: Dreamweaver php form validation and redirect

  #7  
Dec 19th, 2007
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2007
Posts: 2
Reputation: judiglidden is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
judiglidden judiglidden is offline Offline
Newbie Poster

Help Re: Dreamweaver php form validation and redirect

  #8  
Dec 19th, 2007
Originally Posted by nav33n View Post
What is the problem actually ? Because the OP wasn't asking for any help !

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
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,888
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 208
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: Dreamweaver php form validation and redirect

  #9  
Dec 19th, 2007
Originally Posted by judiglidden View Post
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?

By using a header function. Your page should be a php page and not html. I mean, www.lifespringnaz.com/form/lifegroup.html should be www.lifespringnaz.com/form/lifegroup.php to use the php functions. Or you can configure apache so that it parses html files using a php parser(which is lil complicated for time being). After doing whatever you wanna do with the posted form values, use this. header("location: www.lifespringnaz.com/form/confirm.html"); This will redirect the user to "Thank you" page.

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.

This has something to do with the way you have written your script. You are probably having a javascript alert to confirm the sending of email. I don't know about person's email application. We need to look at the code to know what you are talking about.

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


You can use the mail function provided by php. AFAIK, php doesn't change any subject line! Again, you should show us your script to understand the problem.

Cheers,
Nav
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC