FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Email form script - 50 FRIH$

 


freelanceCMS
Hi Guys....i am designing a web page for a hosting company...and they want the contact form configured to allow the user to choose whether the email goes to admin or sales, they need a drop down list that has an attribute with the 'mailto' function..So when the user chooses this option they are emailing say admin or sales depending on what the user chooses from the drop down list.

Can someone please post a script here for this and i will pay 50FRIH$ to 3 PEOPLE ONLY

Cheers and thanks in advance,
Nick
bladesage
freelanceCMS wrote:
Hi Guys....i am designing a web page for a hosting company...and they want the contact form configured to allow the user to choose whether the email goes to admin or sales, they need a drop down list that has an attribute with the 'mailto' function..So when the user chooses this option they are emailing say admin or sales depending on what the user chooses from the drop down list.

Can someone please post a script here for this and i will pay 50FRIH$ to 3 PEOPLE ONLY

Cheers and thanks in advance,
Nick


So wait, are you looking for a simple contact form, with a choice of two possible destinations? You mean with PHP, that sends the form results via email? If so, here's a little something...

Code:
<?php

$admin               = 'someone@domain.com'; // Admin's email address
$sales               = 'someone@domain.com'; // Sales' email address

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Us!</title>
</head>

<body>

<?php

if( !isset($_POST['email']) )
   {
?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

Mail to:<br />
<select name="recipient">
   <option value="admin" selected="selected">Admin</option>
   <option value="sales">Sales</option>
</select><br /><br />

Your email address:<br />
<input type="text" name="email" size="50" /><br /><br />

Your message:<br />
<textarea name="msg" cols="50" rows="4"></textarea><br />

<input type="submit" value="Send!" /><br />
<input type="reset" value="Start over" />

</form>
<?php
   }

else
   {
   $to                  = stripslashes($_POST['recipient']);
   $email               = stripslashes($_POST['email']);
   $msg               = stripslashes($_POST['msg']);
   
   if( $to != 'admin' && $to != 'sales' ) $to   = 'admin';
   $headers            =
   "To: {$to}\r\n" .
   "From: {$email}\r\n" .
   "Reply-To: {$email}";
   
   $addr               = $$to;
   @mail($addr, "Site Contact", $msg, $headers) or die("Error sending message!");
?>Thank you for contacting us!<br /><br />

Your message will be received shortly.
<?php
   }

?>

</body>
</html>


If that's what you meant, simply put the email addresses of admin and sales in the quotes. Everything is labeled with comments (//).

-Alex
cr3ativ3
Hey, it's a pleasure to work with you today here is a simple script that takes the input from a form and sends it to a php script where it emails it, to the requested person.

Code:

<?php
//If the form has been submitted
if (isset($_POST['submitted'])) {
//Collect Variables From The Form
$who = $_POST['who'];
$email = $_POST['email'];
$content = $_POST['content'];
//Figure out the email address
if ($who == "admin") {
$who = "admin@domain.com"; //For admin put email address in the quotes
}elseif ($who == "sales") {
$who = "sales@domain.com"; //For sales put email address in the quotes
} //Add another elseif like above for more emails.

$to = $who; // Email is to.
$subject = "Site Contact Form"; // Subject
$message = $content; // The User's message.
$headers = "From: $email" . "\r\n" . //The email is from the user's email address.
    "Reply-To: $email" . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers); // Send the email.
$self = $_SERVER['PHP_SELF']; //Get the redirect file.
echo "<meta http-equiv='refresh' content='0;url=$self'>"; //Redirect when finished.
}
?>
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Who? <select name="who">
<option>Admin</option>
<option>Sales</option>
</select>
Your Email: <input type="text" name="email" />
Your Message: <textarea name="content"></textarea>
<input type="submit" value="submit" name="submitted" />
</form>
</body>
</html>


That should work, if you would like any further help feel free to ask I commented the php code for you.

Like I said if you would like me to assist you with the script further just ask.
Reply to topic    Frihost Forum Index -> Miscellaneous -> Marketplace

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.