Page 1 of 1

newbi need help!! why the name cannot display after submit ?

Posted: Thu Jan 08, 2004 12:58 am
by newbi
<HTML>
<FORM>
please enter name :<BR>
<INPUT TYPE="text" NAME="username"><BR><BR>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>

<BR>
<?php
echo($username);
?>
</HTML

Posted: Thu Jan 08, 2004 1:26 am
by newbi
what happen to this simple program ? i dont understand why the username cannot pass over to display in php code.

can anyone tell me ? or just test the simple program.
sorry for disturb all here !

Posted: Thu Jan 08, 2004 1:42 am
by Nay
You didn't provide a method for the forum, so it's likely to go into $_GET mode. Do:

Code: Select all

print $_POST['username'];
and have a read at:
viewtopic.php?t=511

-Nay

Posted: Thu Jan 08, 2004 1:55 am
by newbi
it still does't work !

if i enter lengchai in the input textbox
the only changes will be the url :
http://localhost/test.php?username=lengchai


but i still cant display "lengchai"

Posted: Thu Jan 08, 2004 2:01 am
by newbi
OKOK thanks Nay Master
reading my stupid questiong i did solve the problem.
thank you very much !
: )

Posted: Thu Jan 08, 2004 2:02 am
by Nay
Leng Chai? Cantonese? haha.......lei leng meh?

Anyhow like I said, that's because you didn't specify the method.

Code: Select all

print $_GET['username'];
by right it should be:

Code: Select all

<?php

if(isSet($_POST['submit']) {
echo $_POST['username'];
} else {
echo <<< FORM
<form id="form" action="test.php" method="post">
<input type="text" name="username" />
<input type="submit" value="Submit" />
<form>
FORM;
}

?>
-Nay