Reputation: 41919
I'm following a PHP tutorial which is teaching about $_POST and it had me create an exercise with two pages. On the first page (Form page) it creates a form where a user enters Username and Password. Once they click submit, it opens on the second page (process.php) where the Username and Password should be displayed as a result of using $_Post. However, when I click submit on the first page, it takes me to the second page where only the ":" in the Echo statement is displayed. No username, no password.
Any ideas? I've copied the form page and the process.php below.
Form page
<html>
<head>
<title>encode</title>
</head>
<body>
<form action="process.php" method="post">
Username: <input type="text" name="username" value="" />
<br/>
Password: <input type="password" name="password" value=""/>
<br/>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>
Process.php
<html>
<head>
<title>encode</title>
</head>
<body>
<?php
$username = $_Post['username'];
$password = $_Post['password'];
echo "{$username}: {$password}";
?>
</body>
</html>
Upvotes: 2
Views: 3361
Reputation: 298046
As far as I can tell, PHP is case-sensitive when it comes to variable names, so change:
$username = $_Post['username'];
$password = $_Post['password'];
To:
$username = $_POST['username'];
$password = $_POST['password'];
Upvotes: 2
Reputation: 490143
Try using $_POST
(all caps).
Functions are case insensitive, but variables aren't.
Upvotes: 9
Reputation: 145472
Variable names in PHP are case sensitive. You wrote $_Post
where it should be $_POST
Upvotes: 1
Reputation: 10091
$_Post['username']
doesn't work. Must be $_POST['username']
. Same with the password field. You need to enable error reporting in your php.ini configuration file. It would have told you the problem.
Upvotes: 1