Page 1 of 1

HTML/PHP Help >.>

Posted: Tue Oct 30, 2007 10:02 pm
by Dystopia
on my webby for school, im trying to get my text fields to log all entries so my html file looks like


...."
<center><font> Please enter your first and last name.</font></center>
<form action="PHP.php" method="get" autocomplete="off">
First Name: <INPUT name="First Name" value="" size="10"><BR>
Last Name: <INPUT name="Last Name" value="" size="10"><BR>
<CENTER><INPUT type="submit"></CENTER>
</form>"

PHP.php contains

"<?php
header("Location: Home.html");
$handle = fopen("log.txt", "a");
foreach($_GET as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>"

and it should record entries in log.txt

but when i try 2 submit the names 2 see if it recoreded, and nothing comes up in teh log :(

$value) { fwrite($handle, $variable); fwrite($handle, "="); fwrite($handle, $value); fwrite($handle, "\r\n"); } fwrite($handle, "\r\n"); fclose($handle); exit; ?>



btw i have no idea if teh php is right, its probably where the wrong is we didnt take php yet :x

any help pleaseee

Posted: Tue Oct 30, 2007 10:03 pm
by FX
are you trying to hack us???
lol jp i wish i could help ya, im still trying to learn all the lang :/

Posted: Tue Oct 30, 2007 10:04 pm
by Dystopia
i are big noobie, im ehh @ html and big noobie wit php :(

Posted: Tue Oct 30, 2007 10:12 pm
by Millenium
I hate PHP, I'll never code anything myself in it O_O

But I'd suggest you use the DIV tags and set the alignment to center instead of using the HTML CENTER tag.

Posted: Tue Oct 30, 2007 10:47 pm
by Cruor
Sounds like the file is read-only. Also, you can combine variables and strings with a period. :P

Try this:

Code: Select all

<?php
ob_start();
$handle = @fopen("log.txt", "ab") or die("Couldn't open log for writing!");
header("Location: Home.html");
foreach($_GET as $variable => $value)
   fwrite($handle, $variable."=".$value."\r\n");
fwrite($handle, "\r\n");
fclose($handle);
?>
If fopen can't open the file for writing then you'll get the error, otherwise the header will be sent as normal.