Here are the latest errors:
Warning: Wrong parameter count for explode() in new.php on line 4
Warning: file(txt): failed to open stream: No such file or directory in new.php on line 6
Warning: Invalid argument supplied for foreach() in new.php on line 8
Warning: fopen(txt): failed to open stream: Permission denied in new.php on line 15
Fatal error: Call to undefined function: () in new.php on line 16
The form code is:
<form method="POST" action="new.php">
<input type=hidden name="recipient" value="quiz@shapefit.com">
<input type=hidden name="subject" value="Fitness I.Q. Quiz Entry">
<input type=hidden name="print_config" value="email,subject">
<input type=hidden name="redirect"value="http://www.shapefit.com/thankyou-quiz.html">
<input type=hidden name="env_report" value="REMOTE_HOST, HTTP_USER_AGENT">
<input type=hidden name="required" value="FullName,email,Referred By">
<div align="center">
<p><br>
Full Name <br>
<input type="text" name="FullName" size="25">
</p>
<p>Email Address:<br>
<input type="text" name="email" size="25">
</p>
<p>How did you find us?<br>
<input type="text" name="Referred By" size="25">
</p>
<p>If you found us through a search <br>
engine, what were you searching for?<br>
<input type="text" name="Searching For" size="25">
</p>
<p>
<input type="checkbox" name="newsletter" value="newsletter" checked>
Yes, I would like to sign up for your <b>FREE</b> newsletter!<br>
<br>
<br>
<input name="subscribe" type="image" alt="fitness quizzes" src="http://www.shapefit.com/start-quiz2.gif">
</p>
</div>
</form>
The php code is:
<?php
if (isset($_POST['newsletter']) && ($_POST['newsletter']=="newsletter"))
{
$name_arr = explode($_POST['FullName']);
$first_name = $name_arr[0];
$file_arr = file($subscribers.txt);
$found = false;
foreach ($file_arr as $value) {
if (strpos($_POST['email']) !== false) {
$found = true;
break;
}
}
if (!$found) {
$fp = fopen($subscribers.txt, 'a');
$fwrite($fp,$_POST['email'] . ',' . $_POST['FullName'] . "\n");
fclose($fp);
}
}
else $URL="http://shapefit.com/thankyou-newsletter.html";header ("Location: $URL");
?>