Jump to content


Photo

Mailer.php Question


  • Please log in to reply
4 replies to this topic

#1 CTI

CTI
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 April 2006 - 05:09 AM

This is my form:

<form name="form1" method="post" action="mailer.php" onsubmit="return formCheck(this);" >
<table width="303" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="283">Name:
<input name="Name" type="text" id="Name" size="35"></td>
</tr>
<tr>
<td>Email:
<input name="Email" type="text" id="Email" size="35"></td>
</tr>
<tr>
<td><div align="center">
<input name="Reset" type="reset" id="Reset" value="Reset">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>

and this is how I set up my mailer.php, if you need the whole thing, just let me know:


$to = "email@gmail.com"; #this is the email i set up, but i still have not received the email...
$subject = "Member"; #set the subject line
$headers = "Soon to be Member"; #set the from address, or any other headers
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thanks.html"; #set page to redirect to, if 1 is above

does anyone know why I do not get the email when I fill out the form and hit submit?

thanks

#2 bonaparte

bonaparte
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts
  • Location#172, I Floor, 'Hamsashree', Defence Colony, Sahakaranagar, Bangalore, India

Posted 13 April 2006 - 06:24 AM

[!--quoteo(post=364282:date=Apr 13 2006, 12:09 AM:name=CTI)--][div class=\'quotetop\']QUOTE(CTI @ Apr 13 2006, 12:09 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This is my form:

<form name="form1" method="post" action="mailer.php" onsubmit="return formCheck(this);" >
<table width="303" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="283">Name:
<input name="Name" type="text" id="Name" size="35"></td>
</tr>
<tr>
<td>Email:
<input name="Email" type="text" id="Email" size="35"></td>
</tr>
<tr>
<td><div align="center">
<input name="Reset" type="reset" id="Reset" value="Reset">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>

and this is how I set up my mailer.php, if you need the whole thing, just let me know:
$to = "email@gmail.com"; #this is the email i set up, but i still have not received the email...
$subject = "Member"; #set the subject line
$headers = "Soon to be Member"; #set the from address, or any other headers
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thanks.html"; #set page to redirect to, if 1 is above

does anyone know why I do not get the email when I fill out the form and hit submit?

thanks
[/quote]


You never called the mail() function.

[a href=\"http://in.php.net/manual/en/function.mail.php\" target=\"_blank\"]http://in.php.net/manual/en/function.mail.php[/a]

#3 CTI

CTI
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 April 2006 - 01:23 PM

[!--quoteo(post=364299:date=Apr 13 2006, 01:24 AM:name=bonaparte)--][div class=\'quotetop\']QUOTE(bonaparte @ Apr 13 2006, 01:24 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You never called the mail() function.

[a href=\"http://in.php.net/manual/en/function.mail.php\" target=\"_blank\"]http://in.php.net/manual/en/function.mail.php[/a]
[/quote]

OK, so basically it's something like this:

<?PHP mail("toaddress", "subject", "message body", "additional_headers"); ?>

but where do I put that,?

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 13 April 2006 - 03:19 PM

This might not be perfect, but you should get the idea. since you're using the additional headers, I've added a simple spammer hack detector. the mail funciton follows.

mailer.php
<? 
if((strpos($_POST['Name'],"\n",1)) OR (strpos($_POST['Name'],"\r",1)) OR (strpos($_POST['Email'],"\n",1)) OR (strpos($_POST['Email'],"\r",1))) die(); // check for email form hack attempts, if present, do nothing.
mail("email@gmail.com","Subject","Message","From: ".$_POST['Name']." <".$_POST['Email'].">"); 
// if there were no hack attempts, the following HTML will print.
?>
<html>
<head>
<title>Thank You!</title>
</head>
<body>
Thank you for sending me your information.
</body>
</html>


#5 CTI

CTI
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 April 2006 - 05:57 AM

[!--quoteo(post=364451:date=Apr 13 2006, 10:19 AM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 13 2006, 10:19 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This might not be perfect, but you should get the idea. since you're using the additional headers, I've added a simple spammer hack detector. the mail funciton follows.

mailer.php
<? 
if((strpos($_POST['Name'],"\n",1)) OR (strpos($_POST['Name'],"\r",1)) OR (strpos($_POST['Email'],"\n",1)) OR (strpos($_POST['Email'],"\r",1))) die(); // check for email form hack attempts, if present, do nothing.
mail("email@gmail.com","Subject","Message","From: ".$_POST['Name']." <".$_POST['Email'].">"); 
// if there were no hack attempts, the following HTML will print.
?>
<html>
<head>
<title>Thank You!</title>
</head>
<body>
Thank you for sending me your information.
</body>
</html>
[/quote]


Wow thank you very much man. That's awesome! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users