PHP cnotact form/script

Hello everyone i have a small PHP contact script that I use for sites and am now starting to see an issue with it. The scrip work and gets information sent by the user to the designated target, however, it appears that the clients keep getting multiple blank forms a day from the script. Im sure that I just wrote these poorly or something so any advice would be greatly appreciated :slight_smile: here are my scripts:

[php]<?php

$to = “*************@gmail.com” ;
$from = $_REQUEST[‘name’] ;
$email = $_REQUEST[‘email’] ;
$tel = $_REQUEST[‘tel’] ;
$message = $_REQUEST[‘message’] ;
$headers = “From: $from”;
$subject = “Online Contact Form”;

$fields = array();
$fields{“name”} = “Customer Name”;
$fields{“email”} = “Email Address”;
$fields{“tel”} = “Telephone Number”;
$fields{“message”} = “Message”;

$body = “We have received the following information:\n\n”; foreach($fields as $a => $b)
{ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

 $send = mail($to, $subject, $body, $headers);

header( “Location: http://www.*************.com” );

?> [/php]

[php]


Contact






Name :

Email :

Telephone :

Message :





Keep In Touch:

                <ul>
					<li>&nbsp;</li>
					<li class = "white">Tel:</li>
					<li class = "tan">803-464-5779</li>
					<li>&nbsp;</li>
					<li>&nbsp;</li>
					<li class = "white">Email:</li>
					<li class = "tan">[email protected]</li>
				</ul>
				
                <ul id="sm-links">
                	<li><a href="http://www.facebook.com/pages/Mello-Music/335532303142093?ref=ts&fref=ts" class="facebook" target = "_blank" >Facebook</a></li>
                </ul>
            </div>
        </div>
		<div class="bottom-divider"></div>
</div>[/php]

It could be from bots. You can add a captcha, add javascript validation on the form, and add php validation to check for empty values.

Sponsor our Newsletter | Privacy Policy | Terms of Service