PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
devil_online
Forum Newbie
Posts: 5 Joined: Sun Feb 08, 2004 1:07 pm
Post
by devil_online » Sun Feb 08, 2004 1:07 pm
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
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Feb 08, 2004 1:12 pm
It works perfectly fine.. make sure you are running the code on a php enabled server.
devil_online
Forum Newbie
Posts: 5 Joined: Sun Feb 08, 2004 1:07 pm
Post
by devil_online » Sun Feb 08, 2004 1:14 pm
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
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Feb 08, 2004 1:20 pm
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>
devil_online
Forum Newbie
Posts: 5 Joined: Sun Feb 08, 2004 1:07 pm
Post
by devil_online » Sun Feb 08, 2004 2:22 pm
it gives me this error. And the easyphp it is working. I think it's something about the program...
DuFF
Forum Contributor
Posts: 495 Joined: Tue Jun 24, 2003 7:49 pm
Location: USA
Post
by DuFF » Sun Feb 08, 2004 4:14 pm
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>
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Feb 08, 2004 4:37 pm
I got him to install apache and the script worked fine.. :S gg easyphp
devil_online
Forum Newbie
Posts: 5 Joined: Sun Feb 08, 2004 1:07 pm
Post
by devil_online » Sun Feb 08, 2004 5:38 pm
now it says Apache cannot be runned: another web server use the web port. What can I do to correct this? thanks