Location: PHPKode > scripts > Free Feedback Form > Feedback/feedback.php
<? session_start();
$cansend=$HTTP_POST_VARS['cansend'];
if($cansend==1) { 
	$name=$HTTP_POST_VARS['txtName'];
	$cname=$HTTP_POST_VARS['txtCname'];
	$email=$HTTP_POST_VARS['txtEmail'];
	$type=$HTTP_POST_VARS['cboType'];
	$subject=$HTTP_POST_VARS['txtSubject'];
	$message=$HTTP_POST_VARS['txtMessage'];
	$mailto=$type;
	$mailfrom=$email;
	$headers  = "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	$headers .= "From: ". $mailfrom."\r\n";
	$mailbody= '<table width="50%" border="0" align="center" cellpadding="5" cellspacing="2">';
	$mailbody.='<tr> <td colspan="2"><strong><font size="+1">Feed Back</font></strong></td></tr>';
	$mailbody.='<tr><td width="23%">Name</td><td width="77%">'.$name.'</td></tr>';
	$mailbody.='<tr><td>Company Name</td><td>'.$cname.'</td></tr>';
	$mailbody.='<tr><td>Email</td><td>'.$email.'</td></tr>';
	$mailbody.='<tr><td>Type</td><td>'.$type.'</td></tr>';
	 $mailbody.='<tr><td>Message</td><td>'.$message.'</td></tr>';
	if(mail($mailto,$subject,$mailbody,$headers)) $message=" Thank You for your Feedback";
		else $message="There is problem in sending your Feedback this time try again later";

}
?>
<html>
<head>
<title>::: Feedback Forms :::</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="style/feedback.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#f7f7f7" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
			  <form name="form1" method="post" action="feedback.php" onSubmit="return validate()">

<table width="75%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/bg.jpg" style=" border-left:1px solid #7f7f7f; border-right:1px solid #7f7f7f; border-bottom:1px solid #7f7f7f; ">
  
  <tr>
    <td colspan="10"><img src="images/logo.jpg" width="179" height="80" /></td>
  </tr>
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td colspan="8">&nbsp;</td>
  </tr>

  <tr>
    <td width="2%" bgcolor="#EDEEFC" style="border-bottom:1px solid #cccccc; border-top:1px solid #cccccc">&nbsp;</td>
    <td width="22%" bgcolor="#EDEEFC" style="border-bottom:1px solid #cccccc;border-top:1px solid #cccccc"><b class="emailtxt">Feed back </b></td>
    <td colspan="8" bgcolor="#EDEEFC" style="border-bottom:1px solid #cccccc;border-top:1px solid #cccccc">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td colspan="8">&nbsp;</td>
  </tr>
        <?php
		 if($message) {
		 ?>
                <tr><td align="center" colspan="6" class="highlight1"><?php echo $message;?></td>
                </tr>
                <?php
		 }
		
		?>
   <tr>
    <td colspan="2">&nbsp;</td>
    <td colspan="8">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="26%" valign="top"><span class="text">Name: </span></td>
    <td colspan="7"><input name="txtName" type="text" class="text1"  style="width:250" maxlength="150" /></td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>
  
  
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top"><span class="text">Company Name: </span></td>
    <td colspan="7"><input name="txtCname" type="text" class="text1"  style="width:250" maxlength="150" /></td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top"><span class="text">E-mail id: </span></td>
    <td colspan="7"><input name="txtEmail" type="text" class="text1"  style="width:250" maxlength="150" /></td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>

  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top"><span class="text">Type of Feedback: </span></td>
    <td colspan="7"><select name="cboType" id="cboType">
                      <option value="">Select</option>
		<?
		$cn = fopen("feedtype.txt","r");

		while(!feof($cn))
		{
			$str = fgets($cn);
			if(trim($str) != "")
			{
				$str1 = trim(substr($str,0,strpos($str,"-")-1));
				$str2 = trim(substr($str,strpos($str,"-")+1));
				echo "<option value=\"$str2\">$str1</option>";
			}
		}
		?>
		</select>
		</td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top"><span class="text">Subject: </span></td>
    <td colspan="7"><input name="txtSubject" type="text" class="text1"  style="width:250" maxlength="150" /></td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>

  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top"><span class="text">Message: </span></td>
    <td colspan="7"><input name="txtMessage" type="text" class="text1"  style="width:250" maxlength="150" /></td>
  </tr>
  <tr>
    <td colspan="10">&nbsp;</td>
  </tr>
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td width="11%"><input name="submit" type="submit" class="redbutton" value = "Submit" /></td>
    <td width="39%" colspan="6"><input name="reset" type="reset" class="redbutton" value = "Reset" /></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="6">&nbsp;</td>
  </tr>
</table>
<input type="hidden" name="cansend" value="0"> 
           </form> <br><b><center>
            </center>
</center>
</body>
</html>
<script language="JavaScript">
function validate()
{ 
	if(trim(document.form1.txtName.value) == "")
	{
		alert("Please Enter Your Name");
		document.form1.txtName.focus();
		return false;
	}
	if(trim(document.form1.txtCname.value) == "")
	{
		alert("Please Enter Your Company Name");
		document.form1.txtCname.focus();
		return false;
	}
	
	if(trim(document.form1.txtEmail.value) == "")
	{
		alert("Please Enter Your Email Id");
		document.form1.txtEmail.focus();
		return false;
	}
	if( !isEmail(document.form1.txtEmail.value) )
	{
		alert("Please Enter the Valid Email Id");
		document.form1.txtEmail.focus();
		document.form1.txtEmail.select();
		return false;
	}
	if(document.form1.cboType.value == "")
	{
		alert("Please Select ypur Feedback Type");
		document.form1.cboType.focus();
		return false;
	}
	if(trim(document.form1.txtSubject.value)=="") {
		alert("Please Enter a Subject");
		document.form1.txtSubject.focus();
		return false;
	}
	if(trim(document.form1.txtMessage.value)=="") {
		alert("Please Enter a Message");
		document.form1.txtMessage.focus();
		return false;
	}
	
	document.form1.cansend.value=1;
	return true;
}
function isEmail(emailstr)
{
	dotchar = emailstr.indexOf(".");
	atchar = emailstr.indexOf("@");
	dotlast = emailstr.lastIndexOf(".");
	spacechar = emailstr.indexOf(" ");
	len = emailstr.length;
	if( (dotchar == -1) || (atchar == -1) || (spacechar != -1) || (dotlast < atchar) || (dotlast == len - 1) )
	{
		return false;
	}
	else
	{
		return true;
	}
}
function trim(str)
{
ch = '';
for(i=0;i<str.length;i++)
{
	cha = str.charAt(i);
	if(cha != ' ')
	{
		ch = ch + cha;
	}
}
return ch;
}

</script>

Return current item: Free Feedback Form