Page 1 of 1
newbie question
Posted: Sun Feb 08, 2004 1:07 pm
by devil_online
Hi, I'm learning PHP in this moment and my tuturial give me this code:
Code: Select all
<HTML>
<FORM>
Please type your name here:<BR>
<INPUT TYPE=TEXT NAME=username><BR><BR>
<INPUT TYPE=SUBMIT VALUE="Submit data">
</FORM>
<BR><BR>
You typed:
<?php
echo ($username);
?>
</HTML>
But it won't work. Why? Thanks
Posted: Sun Feb 08, 2004 1:12 pm
by John Cartwright
It works perfectly fine.. make sure you are running the code on a php enabled server.
Posted: Sun Feb 08, 2004 1:14 pm
by devil_online
I'm using easyphp.
it gives me this error:
Notice: Undefined variable: username in c:\program files\easyphp1-7\www\teste\teste.php on line 12
Posted: Sun Feb 08, 2004 1:20 pm
by John Cartwright
Are you sure it is working fine? Because I have tested it and it works fine. Try something like this and tell me if it works.
<HTML>
<FORM>
Please type your name here:<BR>
Code: Select all
<INPUT TYPE=TEXT NAME=username><BR><BR>
<INPUT TYPE=SUBMIT VALUE="submitdata">
</FORM>
<BR><BR>
You typed:
<?php
if (SUBMIT=="submitdata") {
echo ($username);
}
?>
</HTML>
Posted: Sun Feb 08, 2004 2:22 pm
by devil_online
it gives me this error. And the easyphp it is working. I think it's something about the program...
Posted: Sun Feb 08, 2004 4:14 pm
by DuFF
That tutorial seems kind of old, so you should probably look for a newer one. Try doing this instead (XHTML and PHP v4.2.0+ compliant

).
Code: Select all
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Basic Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Please type your name here:<br />
<input type="text" name="username" /><br /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<br /><br />
You typed:
<?php
if ($_POST['submit'] == "Submit")
{
echo $_POST['username'];
}
?>
</body>
</html>
Posted: Sun Feb 08, 2004 4:37 pm
by John Cartwright
I got him to install apache and the script worked fine.. :S gg easyphp
Posted: Sun Feb 08, 2004 5:38 pm
by devil_online
now it says Apache cannot be runned: another web server use the web port. What can I do to correct this? thanks
Posted: Sun Feb 08, 2004 7:49 pm
by John Cartwright
uninstall easyphp