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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.