<?php
echo '<h1>Message area</h1>';
echo '<form action="message.php" method="GET ">';
echo 'Username:<input type="text" name="username" /><br />';
echo 'Message:<textarea name="content"></textarea><br />';
echo '<input type="submit" value= "Confirm" />';
echo '</form>';
##?>
Why can’t I receive the $username and $content variables in the form?
I took your code and tested it locally. I can receive the parameters. I will test step by step to see where the problem is.
<?phpecho '<h1>留言区</h1>';echo '<form method="GET">';echo '用户名:<input type="text" name="username" /><br />';echo '留言:<textarea name="content"></textarea><br />';echo '<input type="submit" value="确认" />';echo '</form>';$username=isset($_GET['username']);$content=isset($_GET['content']);$file=fopen('message.txt','a');$w_content="$username : $content";fwrite($file,$w_content);//fclose($file);echo file_get_contents('message.txt');?>建议在传值的时候加上isset方法
No problem with passing value. I tested it locally but the echo data should be wrong
Is
undefined index?
What is the error message?
Are you sure the action in your form points to the correct direction?