keywolf
12-14-2006, 02:21 PM
Hi Guys
Ive made a PHP contact form but cant seem to make a handler that works
the PHP form code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana;
font-size: 12px;
}
-->
</style>
</head>
<body>
<form action="sendemail.php" method="post" class="style1">
<div align="left">Your Name:
<input type="text" name="visitor" size="35" />
<br />
<br />
Your Email:
<input type="text" name="visitormail" size="35" />
<br />
<br />
Department
:
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br />
<br/>
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br/>
<br/>
Your IP:<?php echo $ipi ?><br />
<br/>
<input type="submit" value="Send Mail" />
<br/>
</div>
</form>
</body>
</html>
I need a handler where if they select sales it sends to sales@yourdomain.com and if you choose techinical it sends to support@yourdomain.com etc
Many thanks
keywolf
12-14-2006, 02:24 PM
Also can someone help get the your IP part working so it displays in a box
Thanks
JBreits
12-15-2006, 04:41 PM
Can you describe the problem you are having a little better? I can probably help if I can figure out what you are looking for.
Also, I'm not sure I understand what you mean about putting the IP address in a box. Do you mean in an input box, or you just want it surrounded by an outline?
--
JBreits
keywolf
12-15-2006, 04:49 PM
IP Address in an Input box
The problem i am having is i cannot get it to send to multiple addresses depending on what department they have chosen to send it to
So if they choose sales it will send to the sales email adress and if they choose support it will send to the support email address etc
JBreits
12-15-2006, 05:08 PM
For the IP address thing, you could do something like this (assuming that $ipi is a defined variable).
<input type="text" name="ipaddress" size="35" value="<?php echo $ipi ?>" />
Your sendemail.php is your handler. In there, you need to check the value of $_POST['attn'] to determine which address to send to. Or are you trying to send to multiple e-mail addresses? Like if they choose sales, are you trying to send to abc@abc.com and def@abc.com?
--
JBreits
keywolf
12-15-2006, 05:48 PM
the way itl work is if they choose sales it sends to sales and if they choose support it sends to support
Could anyone right me a handler for this script
JBreits
12-15-2006, 05:59 PM
You need to do something like the following in the handler:
if ($_POST['attn'] == ' Sales n Billing ')
{
$to = 'sales@abc.com';
}
elseif ($_POST['attn'] == ' General Support ')
{
$to = 'support@abc.com';
}
elseif ....
Then you just send the e-mail to whoever is stored in $to.
--
JBreits
keywolf
12-16-2006, 02:47 AM
Could someone write one please as my php coding of form handlers is not brilliant
keywolf
12-16-2006, 03:02 AM
So far ive got
Contact.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana;
font-size: 12px;
}
-->
</style>
</head>
<body>
<form action="sendeail.php" method="post" class="style1">
<div align="left">Your Name:
<input type="text" name="visitor" size="35" />
<br />
<br />
Your Email:
<input type="text" name="visitormail" size="35" />
<br />
<br />
Department
:
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br />
<br/>
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br/>
<br/>
<input type="text" name="ipaddress" size="35" value="<?php echo $ipi ?>" />
<br/>
<input type="submit" value="Send Mail" />
<br/>
</div>
</form>
</body>
</html>
The IP address doesnt work
and the formhandler which doesnt work: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->
<?php
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;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$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";
mail if ($_POST['attn'] == ' Sales n Billing ')
{
$to = 'sales@xtremehosts.co.uk';
}
elseif ($_POST['attn'] == ' General Support ')
{
$to = 'support@xtremehosts.co.uk';
}
elseif ($_POST['attn'] == ' Webmaster ')
{
$to = 'webmaster@xtremehosts.co.uk';
}
($subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="thankyou.php"> Next Page </a>
</p>
</body>
</html>
Shakehost-Chris
12-16-2006, 04:33 AM
here is something that will make your ip show up <?php echo $_SERVER["REMOTE_ADDR"]; ?> that works I tested your script I notice you had an error line 34 now I got another mail script for you that works great .. has features just like yours .. it just has alot more to it .. but it's more easier to understand ..
keywolf
12-16-2006, 07:05 AM
Cheers
Can we see your script :)
as you can see my PHP isnt great lol
keywolf
12-17-2006, 05:39 PM
anyone else able to help?