Jump to content

Recommended Posts

Does anyone have any suggestions for a PHP script that will prevent spammers from injecting e-mails into a request form?  I've pasted my html form and php file below:

 

HTML script:

 

<html>

 

<head>

<title>Request Form</title>

</head>

 

<body background="#EEEEEE">

<div align="center"><img src=""><img src=""></div><br>

<h3 align="center"> Information Request Form</h3>

<div>

<form action="feedback.php" method="post">

 

<p><font color="blue">Thank you for visiting the web page for "Company Name". If you would like more information, please fill out the information in the form below. When finished, click on the "Submit" button. Be sure to include your e-mail or phone so that the Director can follow up with you.</font></p>

<hr width="100%">

<p>Name:&nbsp&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="name"></p>

<p>E-mail:&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="email"></p>

<p>Phone:&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="phone"></p>

Please add any comments or questions in the box below:<br>

<TEXTAREA NAME="comments" ROWS=10 COLS=60>

</TEXTAREA>

<br><br>

<input type="submit" name="submit" value="Submit"><br<br>

<hr width="100%">

 

</div>

</body>

 

</html>

 

PHP script:

 

<html>

<body>

 

<?php

$formBody = "Name:$name\nEmail:$email\nPhone:$phone\nComments:$comments";

$headers = "From:$email";

 

if ($submit) {

mail("[email protected]","Youth Fellowship Information Request",$formBody,$headers);

}

if ($submit) {

print "Thank you, your request has been submitted <br /><br />";

print "Current date and time:  ";

print date("F j, Y, g:i A  T");

}

?>

 

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/109335-php-script-to-improve-security/
Share on other sites

Guest
This topic is now 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.