This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > September 2004 > Contact us form/PHP





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Contact us form/PHP
rjoiram

2004-09-06, 4:15 am

Hello everyone!

I am trying to make a contact us form that emails to me, but I am having a lot
of problems. After searching a lot of websites I finally found a limited
generated script, which I didn't like, so I found a tutorial on the website.
I came up with this:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

?>

this is my form code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td>Name:</td><td><input type="text" name="name" size="25" /></td></tr>
<tr><td>Email address:</td><td><input type="text" name="email" size="25"
/></td></tr>
<tr>
<td colspan="2">
Comments<br />
<textarea rows="15" cols="45" name="comments">
</textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Feedback" /><br />
<a href="http://www.thesitewizard.com/">Powered by thesitewizard.com</a>
</td>
</tr>
</table>
</form>
</body>
</html>

I got this from the generated code


now when I click submit I don't get the email

any ideas?

Thanks in advance...

Joe Makowiec

2004-09-06, 4:15 am

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> now when I click submit I don't get the email
>
> any ideas?


Yup. You still have to send the email:

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";

mail($mailto, $subject, $comments, $headers);

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-06, 7:14 am

thanks, I hope it works :)
rjoiram

2004-09-06, 7:14 am

Okay, I must be really stupid. It didn't work. this is the code I used:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";

mail($mailto, $subject, $comments, $headers);
header( "Location: $thankyouurl" );
exit ;

?>

did I do something wrong?

Joe Makowiec

2004-09-06, 7:14 am

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

You may have received an email at the mario@two... address.

> if (
> mail($mailto, $subject, $comments, $headers);
> ) { echo "<h1>Mail sent successfully</h1>\n"; }


My mistake - remove the semicolon at the end of the second line above,
thus:

if ( mail($mailto, $subject, $comments, $headers) )
{ echo "<h1>Mail sent successfully</h1>\n"; }


--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Joe Makowiec

2004-09-06, 7:14 am

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> Okay, When I click submit, I get this message
>
> To: mario@twohomepros.com
> Subject: Contact The Two Home Pros
> Comments: Hello, this is a test
> Headers: From: Mario
>
> but I don't get the email


Is that all? You didn't get <h1>Mail sent successfully</h1>?

That indicates that the mail is not getting sent. It's possible that
your hosting provider has shut off the mail() function in PHP. Ask
them about it.

One last trial before you do that:

This and only this in a file:

<?php
if ( mail("me@myisp.invalid", "Test subject", "Body Content") )
{ echo "<h1>Mail sent successfully</h1>\n"; }
?>

If that doesn't go, the problem is on hour hosting provider's end.

Replace me@myisp.invalid with a valid email address you own; I hate
posting real email addresses to usenet 'cause they get harvested
rapidly.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-06, 12:15 pm

Okay, When I click submit, I get this message

To: mario@twohomepros.com
Subject: Contact The Two Home Pros
Comments: Hello, this is a test
Headers: From: Mario

but I don't get the email

My code:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";
// Add:

echo"<pre>To: $mailto\nSubject: $subject\nComments: $comments\nHeaders:
$headers</pre>";


if ( mail($mailto, $subject, $comments, $headers) )
{ echo "<h1>Mail sent successfully</h1>\n"; }


Thanks for still helping me, no like seriously I am a complete newbie and I
have no Idea what I'm doing and your making it SO much easier.

Cathy Czuleger

2004-09-06, 12:15 pm

Hi,

There was no closing PHP tag on that last bit of code....could be that.
rjoiram

2004-09-06, 12:15 pm

do I replace the other mail() in my other script so it goes:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";
// Add:

echo"<pre>To: $mailto\nSubject: $subject\nComments: $comments\nHeaders:
$headers</pre>";


if ( mail($mailto, $subject, $comments, $headers) )
{ echo "<h1>Mail sent successfully</h1>\n"; }

<?php
if ( mail("me@myisp.invalid", "Test subject", "Body Content") )
{ echo "<h1>Mail sent successfully</h1>\n"; }
?>

oh yeah, the hosting provider is go daddy do you know anything about them??

and thanks for the info about harvesters.
If you want here is a website that encodes email for websites

http://automaticlabs.com/products/enkoderform/

thanks again

rjoiram

2004-09-06, 12:15 pm

No, I tried that, but thanks for pointing that out.

Thanks anyway
rjoiram

2004-09-06, 12:15 pm

I've tried lots of things, should i put the code at the end or in the middle?
Joe Makowiec

2004-09-06, 12:15 pm

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> do I replace the other mail() in my other script so it goes:


Nope, that script and only that script, just as it was in the message.
Put it in a file, say testphpmailer.php, and surf to that page. You'll
get nothing in your browser, but if the mail function works, you should
get an email.

> oh yeah, the hosting provider is go daddy do you know anything
> about them??


I use them for some of my domain names.

> and thanks for the info about harvesters.
> If you want here is a website that encodes email for websites


Personally, I prefer the method we're trying to get working for you.
That way, the address /never/ appears client side, so it's no problem.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-08, 7:15 pm

Okay, I must be really stupid. It didn't work. this is the code I used:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";

mail($mailto, $subject, $comments, $headers);
header( "Location: $thankyouurl" );
exit ;

?>

did I do something wrong?

Joe Makowiec

2004-09-08, 7:16 pm

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> did I do something wrong?


Let's try some debugging:

> // Add a 'From' header
> $headers = "From: ";
> $headers .= $name . " <";
> $headers .= $email . ">";

// Add:

echo "<pre>To: $mailto\nSubject: $subject\nComments: $comments\nHeaders: $headers</pre>";

if (
mail($mailto, $subject, $comments, $headers);
) { echo "<h1>Mail sent successfully</h1>\n"; }

// Comment out or delete:
> header( "Location: $thankyouurl" );
> exit ;


What do you get?

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-08, 11:15 pm

I get an error page when i click submit
It says:
Parse error: parse error, unexpected ';' in
d:\hosting\twohomepros\Real\iib.php on line 29

I don't get the email

This is my code:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: ";
$headers .= $name . " <";
$headers .= $email . ">";
// Add:

echo"<pre>To: $mailto\nSubject: $subject\nComments: $comments\nHeaders:
$headers</pre>";

if (
mail($mailto, $subject, $comments, $headers);
) { echo "<h1>Mail sent successfully</h1>\n"; }



Thanks for still helping me :)

Joe Makowiec

2004-09-08, 11:16 pm

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

You may have received an email at the mario@two... address.

> if (
> mail($mailto, $subject, $comments, $headers);
> ) { echo "<h1>Mail sent successfully</h1>\n"; }


My mistake - remove the semicolon at the end of the second line above,
thus:

if ( mail($mailto, $subject, $comments, $headers) )
{ echo "<h1>Mail sent successfully</h1>\n"; }


--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Joe Makowiec

2004-09-09, 7:17 pm

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> Okay, When I click submit, I get this message
>
> To: mario@twohomepros.com
> Subject: Contact The Two Home Pros
> Comments: Hello, this is a test
> Headers: From: Mario
>
> but I don't get the email


Is that all? You didn't get <h1>Mail sent successfully</h1>?

That indicates that the mail is not getting sent. It's possible that
your hosting provider has shut off the mail() function in PHP. Ask
them about it.

One last trial before you do that:

This and only this in a file:

<?php
if ( mail("me@myisp.invalid", "Test subject", "Body Content") )
{ echo "<h1>Mail sent successfully</h1>\n"; }
?>

If that doesn't go, the problem is on hour hosting provider's end.

Replace me@myisp.invalid with a valid email address you own; I hate
posting real email addresses to usenet 'cause they get harvested
rapidly.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-09, 7:17 pm

No, I tried that, but thanks for pointing that out.

Thanks anyway
Joe Makowiec

2004-09-09, 7:18 pm

On 05 Sep 2004 in macromedia.dreamweaver, rjoiram wrote:

> do I replace the other mail() in my other script so it goes:


Nope, that script and only that script, just as it was in the message.
Put it in a file, say testphpmailer.php, and surf to that page. You'll
get nothing in your browser, but if the mail function works, you should
get an email.

> oh yeah, the hosting provider is go daddy do you know anything
> about them??


I use them for some of my domain names.

> and thanks for the info about harvesters.
> If you want here is a website that encodes email for websites


Personally, I prefer the method we're trying to get working for you.
That way, the address /never/ appears client side, so it's no problem.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
rjoiram

2004-09-17, 7:15 pm

it worked thanks a whole bunch!

I'm so happy

but now i need to upgrade the form a little
so could you help me once I get the new form code?
rjoiram

2004-09-17, 7:15 pm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Two Home Pros - Contact Us - Buying </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0"
bgcolor="#001C43">
<table width="600" border="0" cellspacing="3" cellpadding="3" height="100%"
bgcolor="#FFFFFF">
<tr>
<td valign="top">
<form action="iiib.php" method="post" enctype="iiib.php">
<table width="600" border="0" cellspacing="4" cellpadding="3">
<tr>
<td colspan="2"><font size="-1" face="Arial, Helvetica,
sans-serif">Please
help us serve you more efficiently, by filling out the
following:</font></td>
</tr>
<tr>
<td width="289"><font size="-1" face="Arial, Helvetica,
sans-serif">Full
Name*</font></td>
<td width="289"><font size="-1" face="Arial, Helvetica,
sans-serif">
<input type="text" name="name" size="50" value="">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Home
Number*</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="HomeNo" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Work
Number</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="WorkNo" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Cell
Number</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="CellNo" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Home
Fax</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="FaxNo" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica,
sans-serif">Email*</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="Email" size="50">
</font></td>
</tr>
<tr>
<td valign="top"><font size="-1" face="Arial, Helvetica,
sans-serif">Home
Address</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="HAddress" cols="38" rows="3"></textarea>
</font></td>
</tr>
<tr>
<td valign="top"><font size="-1" face="Arial, Helvetica,
sans-serif">Work
Address</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="WAddress" id="WAddress" cols="38"
rows="3"></textarea>
</font></td>
</tr>
<tr>
<td><p><font size="-1" face="Arial, Helvetica, sans-serif">Moving
Time Frame</font></p></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="movetimeframe" size="50" value="">
</font></td>
</tr>
<tr>
<td valign="top"><font size="-1" face="Arial, Helvetica,
sans-serif">Preferred
Locations</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="Locations" rows="3" cols="38">seperated by
commas (,)</textarea>
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Price
Range</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="price" size="50" value="$ to $">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Number of
Bedrooms</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="beds" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Number of
Bathrooms</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="baths" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Walk to
Public
Transpotation</font></td>
<td><p> <font size="-1" face="Arial, Helvetica, sans-serif">
<label>
<input name="public" type="radio" value="radio" checked>
Yes</label>
<label>
<input name="public" type="radio" value="radio">
No</label>
<br>
</font></p></td>
</tr>
<tr>
<td valign="top"><font size="-1" face="Arial, Helvetica,
sans-serif">Other
Important Features</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="features" rows="3" cols="38"></textarea>
</font></td>
</tr>
<tr>
<td valign="top"><font size="-1" face="Arial, Helvetica,
sans-serif">Describe
your Dream Home</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="Dream" rows="3" cols="38"></textarea>
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Spoken
With
a Lender?</font></td>
<td><p> <font size="-1" face="Arial, Helvetica, sans-serif">
<label>
<input name="lender" type="radio" value="radio" checked>
Yes</label>
<label>
<input name="lender" type="radio" value="radio">
No</label>
<br>
</font></p></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica,
sans-serif">Who?</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="lenderwho" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Closing
Money
Coming From Someone Else?</font></td>
<td><p> <font size="-1" face="Arial, Helvetica, sans-serif">
<label>
<input name="moneyfrom" type="radio" value="radio" checked>
Yes</label>
<label>
<input name="moneyfrom" type="radio" value="radio">
No</label>
<br>
</font></p></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica,
sans-serif">Who?</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input name="moneyfromwho" type="text" size="50">
</font></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Purchase
Contingent
On Home Sale/Rental?</font></td>
<td><p> <font size="-1" face="Arial, Helvetica, sans-serif">
<label>
<input name="contingent" type="radio" value="radio" checked>
Yes</label>
<label>
<input name="contingent" type="radio" value="radio">
No</label>
<br>
</font></p></td>
</tr>
<tr>
<td><font size="-1" face="Arial, Helvetica, sans-serif">Info We
Should
Know to Help Search?</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<textarea name="info" rows="3" cols="38"></textarea>
</font></td>
</tr>
<tr>
<td><div align="right"> <font size="-1" face="Arial, Helvetica,
sans-serif">
<input type="submit" name="Submit" value="Submit">
</font></div></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<input type="reset" name="Submit2" value="Reset">
</font></td>
</tr>
<tr>
<td colspan="2"><font face="Arial, Helvetica, sans-serif"><font
size="-2">*
Indicates required</font></font></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td valign="bottom"><table width="600" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td width="35"><div align="left"><img src="r.GIF" width="28"
height="30"></div></td>
<td> <div align="center"><font size="-1" face="Arial, Helvetica,
sans-serif">Long
& Foster Real Estate<br>
4650 East West Highway / Bethesda, Maryland 20814<br>
301-907-7600</font></div></td>
<td width="35"><div align="right"><img src="house.GIF" width="28"
height="30"></div></td>
</tr>
<tr>
<td colspan="3"><div align="center">&nbsp;&nbsp;&nbsp;<font
size="-2" face="Arial, Helvetica, sans-serif">
<script language = 'JavaScript'>

Gary White

2004-09-17, 11:14 pm

rjoiram wrote:

>it worked thanks a whole bunch!
>
>I'm so happy



Glad to hear it.


Gary
Gary White

2004-09-17, 11:14 pm

rjoiram wrote:

> <td colspan="3"><div align="center">&nbsp;&nbsp;&nbsp;<font
>size="-2" face="Arial, Helvetica, sans-serif">
> <script language = 'JavaScript'>



The web forum tends to truncate longish code. Could you upload the page
somewhere and post a URL?


Gary
rjoiram

2004-09-17, 11:14 pm

http://www.twohomepros.net/1/iiib.htm - form url

http://www.twohomepros.net/1/iiib.php - PHP url

thanks for helping
rjoiram

2004-09-17, 11:14 pm

is there something that dosn't work in an email form like radio buttons or something?
Gary White

2004-09-18, 12:14 pm

rjoiram wrote:

>http://www.twohomepros.net/1/iiib.htm - form url
>
>http://www.twohomepros.net/1/iiib.php - PHP url
>
>thanks for helping



You're welcome. Try this:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/Real/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/Real/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/Real/thank.htm" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;

foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: $name <$email>";

if (mail($mailto, $subject, $msg, $headers)){
header( "Location: $thankyouurl" );
exit ;
}
echo "Failed to send e-mail";
?>


Gary
rjoiram

2004-09-18, 12:14 pm

I don't get the email

code:

<?php
$mailto = 'mario@twohomepros.com' ;
$subject = "Contact The Two Home Pros" ;
$formurl = "http://www.twohomepros.net/1/ContactUs.htm" ;
$errorurl = "http://www.twohomepros.net/1/error.htm" ;
$thankyouurl = "http://www.twohomepros.net/1/thank.htm" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;

foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}

// Add a 'From' header
$headers = "From: $name <$email>";

if (mail($mailto, $subject, $msg, $headers)){
header( "Location: $thankyouurl" );
exit ;
}
echo "Failed to send e-mail";
?>


when i submit the form, I get a page not found error page and then when I
check my email i dont get the form email

Gary White

2004-09-18, 7:14 pm

"rjoiram" <webforumsuser@macromedia.com> wrote in message
news:cihd3d$bnd$1@forums.macromedia.com...

> when i submit the form, I get a page not found error page and then

when I
> check my email i dont get the form email


Did you save the code I posted as the same file name and path as is
shown in the form's ACTION attribute?

Gary


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews