Hello again great users of this forums!
I use a premade flash movie that sends data to php using post. It checks for @ and . missing but allows ' @ . ' for example.
What I wanna do is only protect the php against running from it self generating a email each time we reload a page (for example the page is mydomain.net/contact.html sending data to mydomain/contact.php if I or anyone else calls the php directly it generates an email...) how can I prevent this if I can't edit the flash? can I do it only in the php file? so that even if someone discover the name of the php file it must not run if anything is posted...
Here's the code (and also: is it secured against injection?):
<?php
$wname = $HTTP_POST_VARS['Name'];
$wemail = $HTTP_POST_VARS['Mail'];
$wmessage = $HTTP_POST_VARS['Message'];
$wassunto = $HTTP_POST_VARS['Ass'];
$ip = $_SERVER['REMOTE_ADDR'];
$wname = str_replace("<?","ERRO",$name);
$wname = str_replace("?>","ERRO",$name);
$wname = str_replace("<","ERRO",$name);
$wname = str_replace("&","ERRO",$name);
$wemail = str_replace("<?","ERRO", $wemail);
$wemail = str_replace("?>","ERRO", $wemail);
$wemail = str_replace("&","ERRO", $wemail);
$wemail = str_replace("<","ERRO", $wemail);
$wmessage = str_replace("<?","ERRO", $wmessage);
$wmessage = str_replace("?>","ERRO", $wmessage);
$wmessage = str_replace("&","ERRO", $wmessage);
$wmessage = str_replace("<","ERRO", $wmessage);
$wassunto = str_replace("<?","ERRO", $wassunto);
$wassunto = str_replace("?>","ERRO", $wassunto);
$wassunto = str_replace("&&","ERRO", $wassunto);
$wassunto = str_replace("<","ERRO", $wassunto);
$message = stripslashes($wmessage);
$sendTo1 = "email_no1@mydomain.net";
$sendTo2 = "email_no2@mydomain.net";
$sendTo3 = "email_no3@mydomain.net";
$sendTo4 = "email_no4@mydomain.net";
$subject = $wassunto;
$msg_body = "Name: $wname";
$msg_body .= " E-Mail: $wemail";
$msg_body .= " IP: $ip\n";
$msg_body .= "Subject: $wassunto\n";
$msg_body .= "Form from website emailed to: $sendTo1\n\n";
$msg_body .= "Commentss: $message\n";
$header_info = "From: ".$wname." <".$wemail.">\r\n\r\n";
mail($sendTo1, $subject, $msg_body, $header_info);
mail($sendTo3, $subject, $msg_body, $header_info);
?>
Can someone help me.
Thank you all in advance,
Regards,
Carlos