Return to Snippet

Revision: 27456
at June 9, 2010 10:52 by vagrantradio


Initial Code
<? include("browser_class.php"); ?> //include class from here http://snipplr.com/view/35627/php-browser-detection-class/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="attSearch.css" type="text/css" />
<style>
body {width:400px;margin:0px auto;text-align:left!important}
h2 {color:green;}
</style>
</head>

<body style="background:none!important;">
<?php
// declare values
$loc = $_COOKIE['location'];
$contact_email = $_POST['EmailAddress'];
$contact_subject = $_POST['Subject'];
$contact_name = $_POST['FullName'];
$contact_message = $_POST['Message'];
$contact_custname = $_SESSION['businessName'];
$contact_accno = $_SESSION['accountNo'];
$mydate = date ( 'l, F d Y g:i A',time()+240 );
// where to send e-mail to
$to = '[email protected]';

// e-mail subject
$subject = "Feedback from $contact_custname";

// e-mail message
$message = "You have received feedback:
"."----------------------------------------------
"
."Contact Name: $contact_name
"
."Business Name: $contact_accno, $contact_custname
"
."Subject: $contact_subject
"
."Submitted: $mydate
"
."From IP: {$_SERVER['REMOTE_ADDR']}
"
."URL: $loc
"
."Browser: $Browser->Name $Browser->Version
"
."Message: $contact_message";

$headers = "From: $contact_name <$contact_email>\n"
."Reply-To: $contact_email\n"
."X-Mailer: PHP/".phpversion();

// check for validation, then send the e-mail
if(empty($contact_name) || empty($contact_email) || empty($contact_subject) || empty($contact_message)) {
echo '<h2>Have feedback?</h2>
<form method="post" action="">
<table id="Form-Details">
<tbody>
<tr><td width="20%">Your Name:</td><td><input type="text" name="FullName" size="40" /></td></tr>
<tr><td width="20%">Subject:</td><td><select name="Subject">
		<option value="Feedback">Feedback</option>
		<option value="Suggestion">Suggestion</option>
		<option value="Bug Report">Bug Report</option>
		<option value="Question">Question</option>
		</select>
</td></tr>
<tr><td width="20%">Email:</td><td colspan="3"><input type="text" name="EmailAddress" size="40" /></td></tr>
<tr><td colspan="4">Message:</td></tr>
<tr><td colspan="4"><textarea rows="6" name="Message" cols="47" class="input"></textarea></td></tr>
<tr><td colspan="4" align="right"><input type="submit" value="Submit Feedback" /></td></tr>
</tbody>
</table>
</form>';
} elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $contact_email)) {
echo "<h2 style='font-weight:bold;color:red;'>ERROR: Please enter a valid e-mail address.</h2>";
} else {
mail( $to, $subject, $message, $headers );
echo "<h2>Message Sent!</h2><br /><p>$contact_name,<br /><br />Thank you for your feedback, we will get back to you as soon as possible using $contact_email.";
}
?>
</body>
</html>

Initial URL


Initial Description


Initial Title
Php Feedback Form w/ Session and Browser Info

Initial Tags
class, php, mail, browser, script, code

Initial Language
PHP