+ 1

What is wrong in this code?!!

<?php header ('Location: http://www.insertyourwebsite.com '); $handle = fopen("user.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;?>

7th Apr 2018, 9:39 AM
OUTSTANDING BOY
2 Réponses
+ 2
Doesn't header ('Location: http://www.insertyourwebsite.com'); redirect your website to the specified URL, and therefore the code below never runs? <?php $handle = fopen("user.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); ?>
7th Apr 2018, 10:31 AM
Emma
0
Have you checked the return value of fopen()? From the documentation (http://php.net/manual/en/function.fopen.php) "Returns a file pointer resource on success, or FALSE on error."
7th Apr 2018, 10:28 AM
Emma