wont $_GET[] form info

A

Anonymous

Guest
I don't understand why, but it just won't get the info from my form.

Form code:
<form name="form1" method="post" action="addlink.php">
<input name="link" type="link" value="http://" size="50">
<input type="submit" name="Submit" value="Foreslå">
</form>

addlink.php code:
<?php
$filename = "addlink.txt";
$content = $_GET['$link'];

if (file_exists($fpn)) {
print($filename);
print('<br>');
print($content);
}
?>

I'm running Apache 2.0 and PHP 4.4.0 on my computer. Do I have to configure anything in php.ini to make it work with $_GET[]?
 
Simple!! Because your form has a POST method :)
You should use $_POST[] array. Use $_GET[] to catch from the URL.
 
now i've changed from $_GET[] to $_POST[] and it still won't work... i'm trying to print it first to make sure it catches the variable from the form, and nothing appears....
 
ohh... thanks... it works now.. but damn I've been looking for hours now after the answer of a new question... how the hell can I write multiple lines to a text file? i've tried to use the file (string) to get the current number of lines and then calculate +1 to it and everything... but i just cant figure it out...
 
Code:
\n
is the same as an enter (make sure you use double quotes)
 
Like this? Because it didn't work.... it wrote to line 1 everytime and added a black square on the ende... probably the ascii sign for enter or something... i don't know...

Code:
<?php
	$filename = "addlink.txt";
	$content = $_POST['link'];
	if (file_exists($filename)) {
		$fp = fopen ($filename, "w");
		fwrite ($fp, "$content\n");
		fclose ($fp);
		chmod ($filename,0777);
	}
	Header ("Location: http://www.nullpunkt.tk/");
?>
 
Back
Top