Code: Select all
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
?>Code: Select all
<?php
if (isset($_REQUEST['email']) && $_REQUEST['email'] != "")
//if "email" is filled out, send email
{
$mailcheck = spamcheck($_REQUEST['email']);
if(!checkEmail($_POST['email']) && $mailcheck==FALSE)
{
//check if the email address is invalid
echo("<script language='JavaScript'>
window.alert('Unvalid email! Please correct it.')
</script>");
echo "<form method='post' action=''>
<table border='0' cellpadding='0' cellspacing='5' style='padding-left:10px' class='contactform'>
<tr>
<th colspan='2' style='font-size:13px; padding:5px; padding-left:0px; text-decoration:underline'>Contact Us Form</th>
</tr>
<tr>
<td>Email</td>
<td> : </td>
<td><input name='email' type='text' class='text' size='30'></td>
</tr>
<tr>
<td>Subject</td>
<td> : </td>
<td><select name='subject' style='width:154px'>
<option value='General'>General</option>
<option value='Enquiry'>Enquiry</option>
</select>
</td>
</tr>
<tr>
<td>Message</td>
<td> : </td>
<td><textarea name='message' rows='6' cols='50'></textarea></td>
</tr>
<tr>
<td colspan='2'><input name='sendemail' type='hidden' class='text' value='1' /></td>
<td style='padding-top:5px'><input type='submit' name='btnSubmit' value='Submit' style='vertical-align:bottom' /></td>
</tr>
</table>
</form>";
}else{
//send email
$email = $_POST['email'] ;
$subject = $_POST['subject'];
$message = $_POST['message'] ;
mysql_query("INSERT INTO feedback(fb_from,fb_subject,fb_content) VALUES ('". $email ."','".$subject."','".$message."')");
if(mysql_affected_rows() == 1){
echo("<script language='JavaScript'>
window.alert('General/Enquiry have been sent! Thank you.')
</script>");
}else{
echo("<script language='JavaScript'>
window.alert('Failed!')
</script>");
}
}
}else
//if "email" is not filled out, display the form
{
echo "<form method='post' action=''>
<table border='0' cellpadding='0' cellspacing='5' style='padding-left:10px' class='contactform'>
<tr>
<th colspan='2' style='font-size:13px; padding:5px; padding-left:0px; text-decoration:underline'>Contact Us Form</th>
</tr>
<tr>
<td>Email</td>
<td> : </td>
<td><input name='email' type='text' class='text' size='30'></td>
</tr>
<tr>
<td>Subject</td>
<td> : </td>
<td><select name='subject' style='width:154px'>
<option value='General'>General</option>
<option value='Enquiry'>Enquiry</option>
</select>
</td>
</tr>
<tr>
<td>Message</td>
<td> : </td>
<td><textarea name='message' rows='6' cols='50'></textarea></td>
</tr>
<tr>
<td colspan='2'><input name='sendemail' type='hidden' class='text' value='1' /></td>
<td style='padding-top:5px'><input type='submit' name='btnSubmit' value='Submit' style='vertical-align:bottom' /></td>
</tr>
</table>
</form>";
}
?>I want to write a page for give customer send feedback form. After submit the form will send mail but i using localhost so i change to another way. Once i fill up the form and submit. It will popup a new windows display subject,message,email(once submit it will insert a query and will delete after display) and the page for feedback form still remain as the fill in form. How to do that can anyone help?