I have written a php script that accepts values from a flash form which has worked fine on several sites. However, I have now uploaded to a new host and it appears that the 'if' statements are ignored and the script continues through the code regardless.
I have added in the 'exit' function to force the code to stop but it still continues. When I post the values from a html/php form it works fine. I have included the code. If anyone could shed some light on this problem I would appreciate it.
Thanks,
Damien.
<?php
if(isset($POST['vemail']))
{
$vemail = $POST['vemail'];
$fp = fopen("email.txt", "r");
while(!feof($fp)) {
$line = fgets($fp, 1024);
if(eregi($vemail, $line)) {
send_response("Email already exists.");
fclose($fp);
exit;
}
}
$fp = fopen("email.txt", "a");
if(!fputs($fp, $vemail . "\r\n")) { send_response("Email failed to save. Try again"); exit();}
fclose($fp);
send_response("Thankyou, we look forward to seeing you soon!");
exit();
}
else
{
send_response("Email failed to save.");
}
function send_response($response)
{
$sendresult = $response;
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo "$send_answer";
}
?>