|
-
Jun 7th, 2005, 08:35 PM
#1
Thread Starter
Addicted Member
why my PHP code not work?
hi all!
i just start to learn PHP.
and i try to get the text from text box by using the code as following:
but it is not work.
PHP Code:
<body>
<form name=login method="post" action="test1.php">
Account <input name=username >
<input type="submit" value="Singed In" id=submit1 name=submit1>
</form>
</body>
</html>
<?
echo "$username";
?>
please help me.
best regards,
Thirith.
Last edited by thirith; Jun 30th, 2005 at 03:15 AM.
-
Jun 8th, 2005, 12:39 AM
#2
Member
Re: why my PHP code not work?
Use $_POST and $_GET to access your form fields:
PHP Code:
<body>
<form name=login method="post" action="test1.php">
Account <input name=username >
<input type="submit" value="Singed In" id=submit1 name=submit1>
</form>
</body>
</html>
<?
echo $_POST['username'];
?>
-
Jun 8th, 2005, 06:24 AM
#3
Re: why my PHP code not work?
the original code will only work if register global variables is turned on and now its turned off be default.
That will also only work is test1.php is the name of the current page.
PHP Code:
<body>
<form name="login" method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>">
Account <input name="username" id="username" />
<input type="submit" value="Singed In" id="submit1" name="submit1" />
</form>
</body>
</html>
<?php
echo $_POST['username'];
?>
Cheers,
RyanJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|