2

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>

4 Answers 4

9

Try using $_POST (all caps).

Functions are case insensitive, but variables aren't.

Sign up to request clarification or add additional context in comments.

7 Comments

It is not about who is "first"!
@Tomalak It does to some degree. Should I answer a day old question with an existing answer reworded?
@alex: 15 seconds != 1 day. Plagiarism and "who beat you to the punch" are not the same thing!
@Tomalak Sometimes it can be difficult to differentiate the two.
@alex: I've never had a problem differentiating between a day and 15 seconds. But maybe that's just me!
|
2

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'];

Comments

1

$_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.

Comments

1

Variable names in PHP are case sensitive. You wrote $_Post where it should be $_POST

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.