Web Hosting Talk







View Full Version : PHP Email Script


Adrnalnrsh
02-18-2005, 12:04 AM
Can anyone tell me why this script isnt working? It's not outputting the results (thanks.php) I have a feeling that its something to do with the sendpage in the form. But am not sure how to fix this. A friend of mine wrote the script using a tutorial a while back. But he can't find it so he asked me.


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

<body bgcolor="#000000">
<?php

// your name

$yourname = "Name";



// your email

$youremail = "email@email.com";



// Default Send Page

$yourdefaultsend = "thanks.php";









if($submitform) {



$dcheck = explode(",",$require);

while(list($check) = each($dcheck)) {

if(!$$dcheck[$check]) {

$error .= "Missing $dcheck[$check]<BR>";

}

}



if($error) {

?>

<div align="center"> <strong><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">THERE
WAS A PROBLEM IN PROCESSING YOUR REQUEST<br>
you must at least fill in your first name and your email address<br>
<font color="#ffffff">Please complete
the form again<br>
If you're still having problems then contact us at <a href="mailto:email@email.com"><font color="red">email@email.com</font></a></font></font></strong></div>
</body>
</html>





<?php
exit();
}

if ($first) {
$yeshow = "\nFrom, $first\n";
}

mail($toemail,"Raffle Request","

\nThis is an email from the mailing list form on your site. The return address you see is the server's address

\nFirst: $first

\nLast: $last

\nEmail: $email

\nAge: $age

\nCity: $city

\nMessage: $message

$yeshow

","From: $first, $email");

header("Location: $sendpage");

exit();

} else {

?>


<div align="center">
<table width="665" border="0" cellspacing="0" cellpadding="5" background="images/back.gif">
<tr>
<td align="center"><br><img src="images/list.gif"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
Please fill out this form the best you can.
You'll be entered in our raffle for a free CD.
</font></div></td>
</tr>
</table>
</div>
<div align="center">
<table width="665" border="0" cellspacing="0" cellpadding="0" background="images/back.gif">
<tr>
<td colspan="2" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="2" valign="top"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
The fields marked with a "*" are required fields.
Thanks, From NAME
</strong></font></div></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td valign="top">&nbsp;</td>
</tr>
<form name="form1" method="post" action="list.php">
<INPUT TYPE="hidden" NAME="subject" VALUE="RSVP">
<INPUT TYPE="hidden" NAME="toemail" VALUE="<?php echo $youremail; ?>">
<INPUT TYPE="hidden" NAME="toname" VALUE="<?php echo $yourname; ?>">
<INPUT TYPE="hidden" NAME="require" VALUE="first,email">
<INPUT TYPE="hidden" NAME="sendpage" VALUE="<?php echo $yourdefaultsend; ?>">
<tr>
<td valign="top"><div align="right"><strong><font face="Arial, Helvetica, sans-serif"><font size="2">*FIRST
- <input name="first" type="text" id="first" size="15">
</font></font></strong></div></td>
<td valign="top">&nbsp;<strong><font size="2" face="Arial, Helvetica, sans-serif">LAST
- </font><font face="Arial, Helvetica, sans-serif"><font size="2">
<input name="last" type="text" id="last" size="15">
</font></font></strong></td>
</tr>
<tr>
<td colspan="2" valign="top"><br><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">*EMAIL
-
<input name="email" type="text" id="email" size="20">
</font></strong></td></div></td>
</tr>
<tr>
<td valign="top"><br><div align="right"> <font size="2" face="Arial, Helvetica, sans-serif"><strong>Your City
-</strong></font>
<input name="city" type="text" id="city" size="15">
</div></td>
<td valign="top"><br><div align="left">&nbsp;<font size="2" face="Arial, Helvetica, sans-serif"><strong>Age
-</strong></font>
<input name="age" type="text" id="age" size="3" maxlength="3">
</div></td>
</tr>
<tr valign="middle">
<td colspan="2"><div align="center"><br><font size="2" face="Arial, Helvetica, sans-serif"><strong>
HOW DID YOU HEAR FROM US? YOU CAN ALSO LEAVE A MESSAGE HERE.
</strong></font><br>
<textarea name="message" cols="50" rows="5" id="message"></textarea>
</div></td>
</tr>
<tr valign="middle">
<td colspan="2"><div align="center">
<p><br>
</p>
</div></td>
</tr>
<tr valign="middle">
<td colspan="2"><div align="center">
<input type="submit" name="submitform" value="Sign Up">
</form>
<br>
&nbsp;
<br>
</div></td>
</tr>
</table>
</div>
<br>
<div align="center"><img src="images/image014.gif" width="150" height="150"></div>
</body>
</html>
<?php

exit();


}



?>

Carp
02-18-2005, 12:13 AM
Right above Header("Location: ......." put:

echo "test";

If test doesnt show on the page then this part of the script isn't even being called.

Adrnalnrsh
02-18-2005, 12:24 AM
I was able to see TEST

Carp
02-18-2005, 03:14 PM
Ok, Then something it wrong with your header.

Type Header("Location: http://www.whatever.com/script.php");

and see if that works.