
Jun 22nd, 2006, 01:57
|
|
New Member
|
|
Join Date: Jun 2006
Location: Minnesota
Age: 31
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Re: Contact us form help!
Here's the script.
- Code: Select all
//Site defines
$SITE_URL = 'http://www.startanursingagency.com';
$SITE_NAME = 'How to start a nursing agency business guide!';
$SITE_EMAIL = 'startanursingagency@gmail.com';
//Check if form is submitted
if($_POST['submitid'] == 1){
if(strlen($_POST['name']) < 3){$message = 'Please enter your name.';}
if(preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $_POST['email']) == false && $message == NULL){ $message = 'Please enter a valid email.';}
//comment following line if you want to make comment optional
if(strlen($_POST['comment']) < 3 && $message == NULL){$message = 'Please enter a comment.';}
//uncomment following line to make phone number mandatory
//if(strlen($_POST['phone']) < 6 && $message == NULL){$message = 'Please enter a phone number.';}
if($message == NULL){
$besttime = $_POST['time'] . ' ' . $_POST['nightorday'] ;
if($_POST['comment'] == NULL){$_POST['comment'] = 'NA';}
if($_POST['phone'] == NULL){$_POST['phone'] = 'NA';}
// This is the Subject of this message
$subj= "A Contact From $SITE_NAME";
// Headers will included The From, Return Email
$header = "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$header .= "From: $SITE_NAME <$SITE_EMAIL>\r\n";
// Header also include the Type, and Language the Email being sent
$header .= "Content-Type: text/html; charset=iso-8859-1;\n\n\r\n";
//Message
$ownermes = '<p><b>Hello '. $_POST[name] .',</b></p>
<p align="justify"><b>We have recieved your contact at: <font color="blue"> ' . $SITE_NAME . ' </font></b></p>
<p align="justify"><b>The message you wrote was: '. $_POST[comment].' </b></p>
<p align="justify"><b>Your telephone number was :<font color="blue"> ' . $_POST[phone] . '</font> </b></p>
<p align="justify"><b>We will be contacting you at :<font color="blue"> ' . $besttime . ' </font></b></p>
<p align="justify"><b>The reason of your contact was :<font color="blue"> ' . $_POST[reason] . '</font> </b></p>
<p align="justify"><b>We will be replying to you at :<font color="blue"> ' . $_POST[email] . '</font> </b></p>
<p align="justify"><b>If there is any change of info, please reply back to us.</b></p>
<p><b>Thank you for your contact,</b></p>
<p><b>'.$SITE_NAME.',</b></p>';
mail ($SITE_EMAIL,"$subj",$ownermes,$header);
mail ($_POST[email],"$subj",$sednermess,$header);
$message = "Your message has been sent, thank you $_POST[name]";
$_POST = NULL;
}
}
?>
<!--
-->
<?php
//Check if we are displaying a message to the user:
if($message != NULL){?>
<?php } ?>
<form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="contactus" id="contactus" style="display:inline;">
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#00CCFF">
</table>
</form>
<form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="contactus" style="display:inline;">
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#00CCFF">
</table>
<table width="78%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#00CCFF">
<tr bgcolor="#99CC99"><td colspan="2" bgcolor="#5A7CA1"><div align="center" class="style1">Contact
Us:</div></td>
</tr>
</table>
</form>
<form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="contactus" style="display:inline;">
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#00CCFF">
</table>
</form>
<form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="contactus" style="display:inline;">
<table width="78%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td width="142" bordercolor="#0066FF"><strong>Your Name:</strong></td>
<td width="305" bordercolor="#0066FF"><font face="Georgia, Times New Roman, Times, serif">
<input name="name" type="text" id="name" value="<?=$_POST['name'];?>" >
</font></td>
</tr>
<tr>
<td bordercolor="#0066FF"><strong>Your E-mail:</strong></td>
<td bordercolor="#0066FF"><font face="Georgia, Times New Roman, Times, serif">
<input name="email" type="text" id="email" value="<?=$_POST['email'];?>" >
</font></td>
</tr>
<tr>
<td bordercolor="#0066FF"><strong>Your Reason of Contact:</strong></td>
<td bordercolor="#0066FF"><font face="Georgia, Times New Roman, Times, serif">
<select name="reason" id="reason">
<?php if($_POST['reason'] == 'Comments'){$sel='selected';}else{$sel=NULL;}?>
<option value="Comments" <?=$sel;?>>Comments</option>
<?php if($_POST['reason'] == 'General Support' || $_POST['reason'] == NULL){$sel='selected';}else{$sel=NULL;}?>
<option value="Support" <?=$sel;?>>General support</option>
</select>
</font></td>
</tr>
<tr>
</tr>
<tr>
<td bordercolor="#0066FF"><strong>Your Message:</strong></td>
<td bordercolor="#0066FF">
<textarea name="comment" rows="4" id="comment" style="width:100%;"><?=$_POST['comment'];?></textarea> </td>
</tr>
<tr>
<td bordercolor="#0066FF">Phone Number:</td>
<td bordercolor="#0066FF"><font face="Georgia, Times New Roman, Times, serif">
<input name="phone" type="text" id="phone" value="<?=$_POST['phone'];?>">
</font></td>
</tr>
<tr>
<td height="84" colspan="2" bordercolor="#0066FF"><div align="center">
<input type="submit" name="Submit" value="Send Message">
<input name="submitid" type="hidden" id="submitid" value="1">
</div></td>
</tr>
</table>
</form>
<br>
Last edited by herkalees; Jun 22nd, 2006 at 02:02.
|