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