Jump to content

Mail Function through templates


GiGalo

Recommended Posts

I am new to php templates and I have this simple mail function that worked until I converted to template. I am trying to accomplish a successful sendMail and redirect to the same page with a success statement. The form is set to onsubmit verify input with JavaScript.

 

This contact page is called through a index template and is referred to as ?p=contact

 

 

Here is my code.

$message = $_GET['usr_find'];
$message .=  "";
$message .= $_GET['message'];
$reason = $_GET['reason'];
$email = $_GET['email'];
$redirect = $_GET['redirect'];

$admin = "admin email address";
$bigtime = "other email";


function sendMail($reason, $email, $message, $admin, $bigtime, $headers ) 
{

  if ($reason == "feedback") 
   {
   	   mail($admin, $reason, $message, $email);
   	   if(
     return true;
   }

  if ($reason == "interested") 
   {
   	   mail($bigtime, $reason, $message, $email );
    return true;
    }
}

?>

<?php

function showForm(){

print <<<_HTML_

<form id="contact" enctype="text/plain" method="GET" name="contact" action="$_SERVER[php_SELF]" onsubmit="return validateForm()">
<input type="hidden" name="redirect" value="http://www.bigtimebordeaux.com/pgs/scrps/contact.php"> 
<fieldset><legend style="color: rgb(0, 0, 0)">Please
use this form to Contact Us:</legend>
<table class="formTable">
<tbody>
<tr>
<td>Your Email Address: <input size="30" name="email" type="text"></td>
</tr>
<tr>
<td>Reason for contact:
<select name="reason">
<option selected="selected" value="not_selected">-Please select one-</option>
<option value="feedback">Site Feedback or Problems</option>
<option value="interested">interested in Service</option>
</td>
</tr>
<tr>
<td>How did you find us:
<select name="usr_find">
<option selected="selected" value="not_selected">-Please select one-</option>
<option value="friend:">Reccomended by Friend</option>
<option value="internetSearch:">Internet Search</option>
</select>
</td>
</tr>
<tr>
<td>Your Message:<br>
<textarea maxsiz="200" name="message" cols="60" rows="10" id="message"></textarea></td>
</tr>
<tr>
<td> <input name="submit" type="submit">
</td>
</tr>
</tbody>
</table>
</fieldset>
</form>
_HTML_;
}


if (isset($_GET['submit'])) {
    sendMail($reason, $email, $message, $admin, $bigtime, $headers );
         echo 'We have successfully recieved your mail. Thank You'; 
            
}else{
showForm();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/260702-mail-function-through-templates/
Share on other sites

A better way to ask is: what is the correct address to put in the hidden redirect input within the form, for the current contact page with a success statement letting the sender know we did receive?

 

input type=hidden name=redirect value=what address to keep template

 

I think I am asking the right questions

 

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.