Jump to content

Question on creating contact form


thumbless

Recommended Posts

It may be helpful to look at this page first:

 

www.fourseasonsbowl.net/contact.htm

 

When clicking on the radio buttons I would like to define two different email address so the email would go to who they selected is this even possible I will include the code I have so far below. By the way the code I have so far was from a tutorial.

 

Who would you like to contact:    o  Office

                                              o  Webmaster

 

<?php

 

/* Subject & Email Variables */

 

$emailSubject = 'Four Seasons Bowl';

$webMaster = '[email protected]';

 

/* Gathering Dada Variable */

 

$emailField = $_POST['email'];

$nameField = $_POST['name'];

$phoneField = $_POST['phone'];

$comentsField = $_POST['coments'];

 

$body = <<<EOD

<br><hr><br>

Email: $email <br>

Name: $name <br>

Phone Number: $phone <br>

Coments: $coments <br>

EOD;

 

$headers = "From: $email\r\n";

$headers .= "Content-type: text/html\r\n";

$success = mail($webMaster, $emaiSubject, $body, $headers);

 

/* Result Rendered as HTML */

 

$theResults = <<<EOD

<html>

<head>

<title>JakesWorks - travel made easy-Homepage</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

<!--

body {

background-color: #f1f1f1;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #666666;

text-decoration: none;

}

-->

</style>

</head>

 

<div>

  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>

</div>

</body>

</html>

EOD;

echo "$theResults";

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/118381-question-on-creating-contact-form/
Share on other sites

This is simple....for once :)

 

Create the radio button and assign it a 'name' and 'value' (email address):

<input type="radio" name="mailwho" value="[email protected]" />
<input type="radio" name="mailwho" value="[email protected]" />

 

then in your php file call the value and put it in a variable:

 

$mailwho = $_POST['mailwho'];

 

then use the variable ($mailwho) as the 'to' address:

 

$to = "$mailwho";

mail ($to ....blahblah blah);

 

I may have missed something, tweak it as you see fit. You'll get the hang of it in no time.

 

 

 

  • 4 weeks later...

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.