Jump to content

my mail script problems


welard

Recommended Posts

<?php


$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
#==================================================================================================
#this looks for email
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
#==================================================================================================
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
#==================================================================================================
#this making sure all fields have been filled 
if(empty($visitor) || empty($visitormail) || empty($notes )) {
#==================================================================================================
echo "<h2>Use Back - Please fill in all fields</h2>\n";
die ("Use back! ! ");
}
#==================================================================================================
#This  is looking  for captcha ======================================================================
session_start();
if ($_POST['captcha'] == $_SESSION['captcha'])
#====================================================================================================
{
$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


if ($attn == "Chairperson")
mail("emailhere", $subject, $message, $from);

if ($attn == "Securtary")
mail("email here", $subject, $message, $from);

if ($attn == "Treausure")
mail("email here", $subject, $message, $from);

if ($attn == "Training")
mail("email here", $subject, $message, $from);

if ($attn == "Expeditions")
mail("email here", $subject, $message, $from);

if ($attn == "Webmaster")
mail("email here", $subject, $message, $from);

?>

 

ok the thing is that it sends a email to Chairperson email but it will not send to the rest

 

shuld i be useing "elseif"?

 

Link to comment
https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/
Share on other sites

if ($attn == "Chairperson")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Securtary")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Treausure")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Training")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Expeditions")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Webmaster")
{
mail("email here", $subject, $message, $from);
}
?>

thanks for the responce

but it did not work am i missing any thing else?

<html>
<head>
<script type="text/javascript" language="JavaScript1.2" SRC="scripts/stm31.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
<style type="text/css">
<!--
body {
background-color: #00CCFF;
}
-->
</style></head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php


$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
#==================================================================================================
#this looks for email
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
#==================================================================================================
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
#==================================================================================================
#this making sure all fields have been filled 
if(empty($visitor) || empty($visitormail) || empty($notes )) {
#==================================================================================================
echo "<h2>Use Back - Please fill in all fields</h2>\n";
die ("Use back! ! ");
}
#==================================================================================================
#This  is looking  for captcha ======================================================================
session_start();
if ($_POST['captcha'] == $_SESSION['captcha'])
#====================================================================================================
{
$todayis = date("l, F j, Y, g:i a") ;
// trying to make it +4 hours more than server time $todayis = time() - (int)substr(date('O'),0,3)*60*60;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


if ($attn == "Chairperson")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Securtary")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Treausure")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Training")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Expeditions")
{
mail("email here", $subject, $message, $from);
}
if ($attn == "Webmaster")
{
mail("email here", $subject, $message, $from);
}
?>
<?php include "mainmenu.php";?>
<p align="center">
<strong>Date:</strong> <?php echo $todayis  ?>
<br />
<strong>Thank You :</strong> <?php echo $visitor ?> <br/>
( <?php echo $visitormail ?> )
<br />

<strong>Attention:</strong> <?php echo $attn ?>
<br />
<strong>Message:</strong><br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo "Your IP $ip"; ?>
<?php }

#This "else" is  for captcha if it is not right nothing will be sent
else

die ("

<p align='center'>
Captcha was not right please go back and retry

");
?>
<br /><br />
<a href="index.php"> Home </a></p>

</body>
</html>

 

here is all the code the captcha is closed at the bottem of the page

let me know how this works out for you:

<?php
session_start();
$html1 = <<<HTML_1
<html>
<head>
<script type="text/javascript" language="JavaScript1.2" SRC="scripts/stm31.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
<style type="text/css">
<!--
body {
background-color:#00CCFF;
}
-->
</style></head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->
HTML_1;
echo $html1;
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
#==================================================================================================
#this looks for email
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
#==================================================================================================
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
#==================================================================================================
#this making sure all fields have been filled 
if(empty($visitor) || empty($visitormail) || empty($notes )) {
#==================================================================================================
echo "<h2>Use Back - Please fill in all fields</h2>\n";
die ("Use back! ! ");
}
#==================================================================================================
#This  is looking  for captcha ======================================================================

if ($_POST['captcha'] == $_SESSION['captcha'])
#====================================================================================================
{
$todayis = date("l, F j, Y, g:i a") ;
// trying to make it +4 hours more than server time $todayis = time() - (int)substr(date('O'),0,3)*60*60;

//this may help with your time offset:
/*
<?php
$date = date_create('2000-01-01');
date_add($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');
?>
*/
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";
$attn = strtolower($attn);
$attn = trim($attn);
switch ($attn){
case "chairperson":
mail("email here", $subject, $message, $from);
break;
case "securtary":
mail("email here", $subject, $message, $from);
break;
case "treausure":
mail("email here", $subject, $message, $from);
break;
case "training":
mail("email here", $subject, $message, $from);
break;
case "expeditions":
mail("email here", $subject, $message, $from);
break;
case "webmaster":
mail("email here", $subject, $message, $from);
break;
default:
  die ("could not find $attn in contacts");
break; 
}
include "mainmenu.php"; 
$notesout = str_replace("\r", "<br/>", $notes);
$html2 = <<<HTML_2
<p align="center">
<strong>Date:</strong> $todayis  
<br />
<strong>Thank You :</strong> $visitor <br/>
( $visitormail )
<br />

<strong>Attention:</strong> $subject 
<br />
<strong>Message:</strong><br />

$notesout
<br />
Your IP $ip
HTML_2;
echo $html2;
}
#This "else" is  for captcha if it is not right nothing will be sent
else{

die ("

<p align='center'>
Captcha was not right please go back and retry

");}
?>
<br /><br />
<a href="index.php"> Home </a></p>

</body>
</html>

Another thing, check your spelling for the $attn values against your form values (don't worry about the case - I forced it to lower case for the comparrison.  Normaly I would have the form values set to key values for an array in that setup, less chance of slipping a typo in when it's only a single number.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.