Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $_POST not working

Tags:

post

php

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>
like image 606
Leahcim Avatar asked Jun 13 '26 19:06

Leahcim


1 Answers

Try using $_POST (all caps).

Functions are case insensitive, but variables aren't.

like image 136
alex Avatar answered Jun 17 '26 16:06

alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!