HighDots Forums  

sending a form

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss sending a form in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Gary White
 
Posts: n/a

Default Re: sending a form - 07-13-2004 , 01:24 AM






On Mon, 12 Jul 2004 23:25:18 +0000 (UTC), "jennsite"
<webforumsuser (AT) macromedia (DOT) com> wrote:

Quote:
ok. switched the code as you suggested. not getting the later errors about
undefined variables name, etc. but still getting runtime error about post
being undefined. And no message is coming through after mail is sent coming
sending to the user. Just a blank page. Though we are moving the mail now.

Perhaps you have a version of PHP older than 4.1.0. Replace the
following four lines:

$name=stripslashes(trim($_POST['name']));
$email=stripslashes(trim($_POST['email']));
$company=stripslashes(trim($_POST['company']));
$message=stripslashes(trim($_POST['message']));

with these:

$name=stripslashes(trim($HTTP_POST_VARS['name']));
$email=stripslashes(trim($HTTP_POST_VARS['email']));
$company=stripslashes(trim($HTTP_POST_VARS['company']));
$message=stripslashes(trim($HTTP_POST_VARS['message']));



Gary


Reply With Quote
  #12  
Old   
jennsite
 
Posts: n/a

Default Re: sending a form - 07-13-2004 , 06:03 PM






nope. my server says its v4.3.0 of php. but i made the changes you suggested
anyway. no change. I just can't figure out if the runtime error is coming
from the page or the php file. which is wrong?


Reply With Quote
  #13  
Old   
jennsite
 
Posts: n/a

Default Re: sending a form - 07-13-2004 , 08:54 PM



I'm a happy girl at the moment because I am getting no errors and we're moving
the mail. I've been following suggestions from three different sources and I
guess some combination finally worked - mostly. At this point, though the mail
sends and there are no errors, the ie window goes to a blank page after 'send'
is hit. No way for the user to know it's sent (even though that's in the code)
and they would have to hit 'back' on the browser to see the page again. I'd
like it to give the 'sent successfully' message at the bottom of the contact
page and clear the fields at the same time. Or give the 'sent successfully'
message and then go back to the contact page with cleared fields. Give a mouse
a cookie and she'll ask for a glass of milk. heh.

as you asked, here's the php file as it now stands:

<?php

//trim whitespace


$name=stripslashes(trim($_POST['name']));
$email=stripslashes(trim($_POST['email']));
$company=stripslashes(trim($_POST['company']));
$message=stripslashes(trim($_POST['message']));

//check email is valid
if (!eregi("^[a-zA-Z0-9_\-\.\-\\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$",
$email))
{
echo "You have entered an invalid email address. Please return to the previous
page and try again.";
exit;
}

//set headers and format email content
$headers = "From: Courtroom Video: Website Enquiry
<jennsite (AT) geary (DOT) k12.ok.us>\n";
$headers .= "Reply-To: ".$email."\n";
$headers .= "X-Sender: <jennsite (AT) geary (DOT) k12.ok.us>\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: <jennsite (AT) geary (DOT) k12.ok.us>\n";
$toaddress = "jennsite (AT) geary (DOT) k12.ok.us";
$mailcontent = "Customers Name: ".$name." \r\n"
."Customers Email: ".$email."\r\n"
."Customers Company: ".$company."\r\n"
."Message: ".$message."\r\n";

//process email and warn if errors encountered
if(mail($toaddress,"Website enquiry from ".$name,$mailcontent,$headers) ==
true) {
$deliverymessage = "<b>Thank you, your enquiry about our services has been
successfully sent, expect a response within one business day.</b>";
}
else {
$deliverymessage = "<b>Sorry, there has been an error with your request.</b>
Please press the back button on your browser and try again.";
}
?>

-----------------------------------------------

here's the form's code:

<?= $deliverymessage ?>
<form action="contactform.php" method="post"
enctype="multipart/form-data" name="form1" id="form1">
<p>&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name:
<input name="name" type="text" class="style2" id="name"
size="24" />
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Company Name:
<input name="company" type="text" class="style2"
id="company" size="24" />
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E-mail address:
<input name="email" type="text" class="style2" id="email"
size="24" />
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comments/Inquiries: </p>
<p>
<textarea name="message" cols="60" rows="8" class="style2"
id="message"></textarea>
</p>
<p align="center">
<input name="Submit" type="submit" class="style2"
id="Submit" value="Send" />

</p>
</form>


Reply With Quote
  #14  
Old   
Gary White
 
Posts: n/a

Default Re: sending a form - 07-14-2004 , 10:30 AM




Quote:
//process email and warn if errors encountered
if(mail($toaddress,"Website enquiry from ".$name,$mailcontent,$headers) ==
true) {
$deliverymessage = "<b>Thank you, your enquiry about our services has been
successfully sent, expect a response within one business day.</b>";
}
else {
$deliverymessage = "<b>Sorry, there has been an error with your request.</b
Please press the back button on your browser and try again.";
}
?

Change the above to this:

//process email and warn if errors encountered
if(mail($toaddress,"Website enquiry from ".$name,$mailcontent,$headers)){
echo "<p><b>Thank you, your enquiry about our services has been
successfully sent, expect a response within one business day.</b></p>
<p><a href=\"/\">Home</a></p>";
}else {
echo "<p><b>Sorry, there has been an error with your request.</b></p>
<p>Please press the back button on your browser and try again.</p>";
}
?>


Gary


Reply With Quote
  #15  
Old   
jennsite
 
Posts: n/a

Default Re: sending a form - 07-15-2004 , 04:31 PM



Gary, I can't thank you enough! It's all working. Just some prettying up and
it'll be done.
This is how the php file wound up, in case anyone wants to know.:

<?php

//trim whitespace


$name=stripslashes(trim($_POST['name']));
$email=stripslashes(trim($_POST['email']));
$company=stripslashes(trim($_POST['company']));
$message=stripslashes(trim($_POST['message']));

//check email is valid
if (!eregi("^[a-zA-Z0-9_\-\.\-\\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$",
$email))
{
header('location: error.html');
exit;
}

//set headers and format email content
$headers = "From: Courtroom Video: Website Enquiry
<jennsite (AT) geary (DOT) k12.ok.us>\n";
$headers .= "Reply-To: ".$email."\n";
$headers .= "X-Sender: <jennsite (AT) geary (DOT) k12.ok.us>\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: <jennsite (AT) geary (DOT) k12.ok.us>\n";
$toaddress = "jennsite (AT) geary (DOT) k12.ok.us";
$mailcontent = "Customers Name: ".$name." \r\n"
."Customers Email: ".$email."\r\n"
."Customers Company: ".$company."\r\n"
."Message: ".$message."\r\n";

if(mail($toaddress,"Website enquiry from ".$name,$mailcontent,$headers)) {
header('location: thankyou.html');
exit;




Reply With Quote
  #16  
Old   
Gary White
 
Posts: n/a

Default Re: sending a form - 07-15-2004 , 04:59 PM



jennsite wrote:

Quote:
Gary, I can't thank you enough! It's all working. Just some prettying up and
it'll be done.

Glad to hear it. You're welcome.


Gary


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.