Forum Moderators: coopster

Message Too Old, No Replies

Form mail php script problem

         

hooper

8:38 pm on Feb 8, 2004 (gmt 0)



I am using a pre-installed script on my website but some of my users are having trouble trying to submit the form and receiving the following message "security violation, unauthorized referrer". Can anybody tell me how to fix this problem as I need to sort it out asap.

Thanks

$url = strtolower($HTTP_HOST);
$url = ereg_replace("www.", "", $url);

if (!ereg($url,$HTTP_REFERER)) DIE ("<html><script language='JavaScript'>alert('Security Violation: Unauthorized referer!'),history.go(-1)</script></html>");

if (($recipient=="") ¦¦ (!ereg("[A-Za-z0-9_-]+([\.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([\.]{1}[A-Za-z0-9-]+)+", $recipient)) ¦¦ (strlen($recipient)>100)) DIE ("<html><script language='JavaScript'>alert('Sorry, this form cannot be submitted!\\\n\\\nReason: Invalid recipient field!\\\n\\\nPlease contact the webmaster for details.'),history.go(-1)</script></html>");

if (($email!="") && (!ereg("[A-Za-z0-9_-]+([\.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([\.]{1}[A-Za-z0-9-]+)+", $email))) DIE ("<html><script language='JavaScript'>alert('Please enter your e-mail address! A valid e-mail address must be in you@yourname.com format.'),history.go(-1)</script></html>");

// trimmed other processing code here - jatar_k

[edited by: jatar_k at 5:51 pm (utc) on Feb. 10, 2004]
[edit reason] reduced to relevant code [/edit]

jatar_k

5:53 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld hooper,

Referers aren't always passed by the browser so it could just be that issue if it isn't always happening. What percentage of your users are having the issue?

You could remove the referer check if the majority of them can't submit it. Then you could just add more checks on the actual fields.

coopster

5:58 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, hooper!

The problem is more than likely with your $HTTP_REFERER variable. You may want to read this thread that asks Where is $HTTP_REFERER? [webmasterworld.com]

<edit>good morning, jatar_k! beat me to this one...</edit> :)