Jump to content

Feedback Form And Script


AlanB09

Recommended Posts

hy there, i have written a basic feedback form and script, and have checked over it, it should run :S

but, alas, it doesnt mail to my account.  any help much appreciated please.  thanks

 

Feedback Form:

 <html>
<head>
<title> Contact us </title>
<body bgcolor="orange">
<center>
</head>

<body>

<h1> Please Give Us Your Feedback</h1>

<form name="feedback" action="sendfeedback.php">
Name: <br />
<input type="text" name="name"><br />

Email:<br />
<input type="text" name="email"><br />

Your Comments: <br /><textarea name="comments" rows="10" cols="30">
</textarea><br />

<input type="submit" name="submit" value="Submit">
</form>

</body>
</html> 

 

sendfeedback.php :

  <html>
<head>
</head>
<body>


<?php

if (isset($_POST['submit'])) {

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['comments'];


mail( "[email protected]" , "Feedback Form Results from VisualizationRicky",
    $message, "From: $name, $email" );
  header( "Location: http://www.visualizationricky.com/index" );

}

else {

header( "Location: http://www.visualizationricky.com/index");


}
}


?>
</body>
</html> 

Link to comment
https://forums.phpfreaks.com/topic/185246-feedback-form-and-script/
Share on other sites

hai

i have done this long back i think u can use this one

<html>
<body>
<style>
body {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:90%;
    margin:150px;
    color:green; }
.fieldset {
    width:10px; }
.fieldset .nobr {
    display:none; }  
.fieldset .textfield {
    margin:3px;
    height:20px;
    width:200px;
    border:solid 0 #fff;
     }
.fieldset .textarea {
    margin:3px;
    height:165px;
    width:200px; }
</style>

<form action="feedback.php" method="post">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<fieldset align="middle">
<legend align="center">Feedback form </legend>
<label for="name" style="color: green; font-family: Verdana;font-weight: bold;font-size: 14px;" maxlength='25'">Name:</label><br/>
<input type="text"  id="nameis" name="nameis"  align="middle" />
<br />
<label for="email" style="color: green; font-family: Verdana;font-weight: bold;font-size: 14px;" maxlength='25'">Email:</label><br/>
<input type="text" id="visitormail" name="visitormail" /><br/>
<label for="website" style="color: green; font-family: Verdana;font-weight: bold;font-size: 14px;" maxlength='25'">Website:</label><br/>
<input type="text" id="website" name="website"  />
<br />
<label for="comment" style="color: green; font-family: Verdana;font-weight: bold;font-size: 14px;" maxlength='25'">Comment:</label><br />
<textarea cols="30" rows="15" name="feedback" id="feedback"  >
</textarea>
<br /><td>Security code: <input class="text" name="secCode" type="text" size="10" /></td>
              <td><img src="securityCode.php" alt="security code" border="1" /></td>
<label for="submit"> </label><br />
<input id="submit" name="submit" type="submit" value="submit" />
</fieldset>
</form>
</body>
</html>
<!--<?php 
echo "<br>12".$ipi."<br>34".$httprefi."<br>11".$httpagenti;
?>-->

<?php

$ip = $_POST['ip'];
$httpagent = $_POST['httpagent'];
$nameis = $_POST['nameis'];
$visitormail = $_POST['visitormail'];
$feedback = $_POST['feedback'];
$feedback = stripcslashes($feedback);
$todayis = date("l, F j, Y, g:i a") ;
$website = $_POST['website'];

// Send email with result to the user
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: [email protected]' . "\r\n";
//$headers .= 'From: xxxxxxxxxxxxxx' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
// Mail it
$subject = "About the site";   

$message = <<<EOF
<table align="center" width="95%" border="0" cellpadding="5" cellspacing="5">
<tr style="background:green;font-color:white;font-weight:strong;">
   <td colspan="2">Feedback</td>
</tr>
    <tr style="background:#F8F8F8">
   <td>Date</td>
   <td>$todayis</td>
   </tr>
   
    <tr style="background:#F8F8F8">
   <td>Http Agent</td>
   <td>$httpagent</td>
   </tr>
   
<tr style="background:#EFEFEF">
   <td>IP Address</td>
   <td>$ip</td>
   </tr>
   
<tr style="background:green;font-color:white;font-weight:strong;">
   <td colspan="2">App Information</td>
</tr>
<tr style="background:#F8F8F8">
   <td>Name</td>
   <td>$nameis</td>
   </tr>
   
<tr style="background:#EFEFEF">
   <td>EMail</td>
   <td>$visitormail</td>
    </tr>
   
<tr style="background:#F8F8F8">
   <td>Website</td>
   <td>$website</td>
   </tr>
   
<tr style="background:#F8F8F8">
   <td>Feedback</td>
   <td>$feedback</td>
   </tr>
  



</table>
EOF;
//echo $message;
if(isset($_POST[submit]))
{
    $secCode = isset($_POST['secCode']) ? strtolower($_POST['secCode']) : "";
    
if($nameis && $visitormail && $feedback )
{
//echo $message;

if (eregi('http:', $feedback)) 
{ 
die ("Do NOT try that! ! ");
}

elseif((!$visitormail == "") && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
//echo "<h2>Enter valid e-mail</h2>\n";
$tellem = "Please enter a Valid Email ID\n";
echo $tellem;
}

elseif(empty($nameis) || empty($feedback) || empty($visitormail)) 
{
echo "Please fill in all fields\n";
}
elseif(($secCode != $_SESSION['securityCode']))
{
    //echo "<br>1".$secCode;
    //echo "<br>2".$_SESSION['securityCode'];
    echo " Please enter the Security Code Correctly";
    unset($_SESSION['securityCode']);
}
elseif(mail("[email protected]", $subject, $message, $headers, "-f".$visitormail))
                {
                    echo "Feedback sent succesfully";
                    unset($_SESSION['securityCode']);    
                }
            else
                {
                    echo "Mail not sent Succesfully";
                    unset($_SESSION['securityCode']);
                }
}
else
{
    echo ("<table><td bgcolor=orange width=100%><font face=Verdana, Arial, Helvetica, sans-serif size=2> Please fill in the details and press submit</font></td></table>");
}
}
else
{
    
}
?>

 

and the code for securityCode.php

 

<?php
session_start();

$width  = 120;
$height =  40;
$length =   5;

$baseList = '0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

$code    = "";
$counter = 0;

$image = @imagecreate($width, $height) or die('Cannot initialize GD!');

for( $i=0; $i<10; $i++ ) {
   imageline($image, 
         mt_rand(0,$width), mt_rand(0,$height), 
         mt_rand(0,$width), mt_rand(0,$height), 
         imagecolorallocate($image, mt_rand(150,255), mt_rand(150,255), mt_rand(150,255)));
}

for( $i=0, $x=0; $i<$length; $i++ ) {
   $actChar = substr($baseList, rand(0, strlen($baseList)-1), 1);
   $x += 10 + mt_rand(0,10);
   imagechar($image, mt_rand(3,5), $x, mt_rand(5,20), $actChar, 
      imagecolorallocate($image, mt_rand(0,155), mt_rand(0,155), mt_rand(0,155)));
   $code .= strtolower($actChar);
}
   
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);

$_SESSION['securityCode'] = $code;

?>

 

i think this would resolve ur query

Archived

This topic is now archived and is closed to further replies.

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