...

View Full Version : This script isn't working and I don't know why



wojo1086
03-26-2010, 04:01 AM
Here's the scoop. I made this html/php script and the php portion doesn't seem to be working. Any reasons why? It's saved as a .php file. The file's name is basicForm.php so the action="basicForm.php" is telling it to go to itself.



<html>
<head>
<title>A BASIC HTML FORM</title>
<?php
$username=$_post['username'];
print($username);
?>
</head>
<body>

<form name="form1" method="post" action="basicForm.php">

<input type="text" value="username">
<input type="submit" name="submit1" value="Login">

</form>
</body>
</html>

hiroshu
03-26-2010, 04:46 AM
try first


<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>


<?php
$username=$_post['username'];
print($username);
?>



<form name="form1" method="post" action="basicForm.php">

<input type="text" value="username">
<input type="submit" name="submit1" value="Login">

</form>
</body>
</html>

wojo1086
03-26-2010, 02:05 PM
Nope. It didn't work.

_Aerospace_Eng_
03-26-2010, 02:32 PM
You need to have a name attribute on the input.

<input type="text" name="username" value="username">

TopDogger
03-26-2010, 03:17 PM
That should work. You need to assign the value to a POST variable. You probably also want to change value="", otherwise you are assigning "username" as the default value.

wojo1086
03-27-2010, 01:40 AM
None of those are working. Got anything else?

Zangeel
03-27-2010, 01:52 AM
<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>


<?php

echo $_POST['username'];

?>



<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<input type="text" value="username" name="username" />
<input type="submit" name="submit1" value="Login" />

</form>
</body>
</html>

If this doesn't work, check if PHP is actually installed.

wojo1086
03-27-2010, 02:08 AM
It works! Thanks everyone!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum