Jump to content
Posted

Hi all,

 

I was wondering if any of the web designers may have some time to help me understand how to create forms (ie contact, feedback, etc) using dreamweaver. I need the form to validate the fields, submit the information to a specific e-mail address in a clear format but not invoke the client's e-mail programme to send the form. I've not been using dreamweaver very long and this is making my head hurt :headvswal .

 

Many thanks in advance!

 

Dan

Featured Replies

If you give me ten mins i'll dig out my php scripts. I assume you're using a php enabled web server? (most of them support it?)





Untitled Document



<br />
	function validate_form ( )<br />
	{<br />
		valid = true;<br />
	<br />
			if ( document.enquiry.Name.value == "" )<br />
			{<br />
					alert ( "Please fill in the 'Full Name' box." );<br />
					valid = false;<br />
			}<br />
			if ( document.enquiry.EmailAddress.value == "" )<br />
			{<br />
					alert ( "Please fill in the 'Email' box." );<br />
					valid = false;<br />
			}<br />
			if ( document.enquiry.Message.value == "" )<br />
			{<br />
					alert ( "Please fill in the 'Comments' box." );<br />
					valid = false;<br />
			}<br />
			return valid;<br />
	}<br />

</pre>
<form name="enquiry" onsubmit="return validate_form ( );" action="FormToMail.php" method="post">
   
       
             
               Name:
           
           
               
           
         
       
           
               Email Address:
           
           
               
           
          
       
           
               Enquiry:
           
           
               
               
           
          
       
            
           
               
           
          
   
</form> <br><br><b

 

Save this as ContactUs.php

//Enter the email address below to send the form to:

$my_email = "nick@delazo.com";
// This line prevents values being entered in a URL

if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}

$Message = "";

// This line prevents a blank form being sent

while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$Message = $Message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

$Message = stripslashes($Message);

$subject1 = "Website Enquiry";
$headers = "From: " . $_POST['EmailAddress'] . "\n" . "Return-Path: " . $_POST['EmailAddress'] . "\n" . "Reply-To: " . $_POST['EmailAddress'] . "\n";

mail($my_email,$subject1,$Message,$headers);

?>
</pre>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
 
         
       
         Thank You
       
       
         Your enquiry has successfully been sent. 
       
       
         Please click here to return to the Welcome page 
       
     
</table

 

Save this as FormToMail.php

Make sure you save them exactly as they're called above, same caps as well. Just tested it and it all works.

 

Cheers,

 

Nick

  • Author
Make sure you save them exactly as they're called above, same caps as well. Just tested it and it all works.

 

Cheers,

 

Nick

 

Thanks very much Nick - I'm about to upload the files and test them. :dance:

 

Best regards,

 

Dan

  • Author
Thanks very much Nick - I'm about to upload the files and test them. :dance:

 

Best regards,

 

Dan

 

Hi Nick,

 

I've uploaded the files and proceeded with testing - got an error. I'm taking this off-line so as not to bore everyone else with the trials and tribulations of my ineptitude as a web designer (novice or otherwise). I'll pm you the error code.

 

Thanks again for your help.

 

Regards,

 

Dan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Important Information

Terms of Use