0

I am not getting any output at all once I enter the details and click on the Register button and being a beginner in php I can't figure out what it is that I'm doing wrong. Here is my code:

<?php

if (isset($_POST["Register"])) {
$name = $_POST["Name"];
$email = $_POST["Email_Address"];
$uname = $_POST["Email_Address"];
$password = $_POST["Password"];

echo $name;
}
?>

The html file is as follows:

    <form action="register.php" method"POST">

    Name: <br>
    <input type="text" name="Name" required><br>
    <br>
    Email Address: <br>
    <input type="email" name="Email_Address" required><br>
    <br>
    Set Password: <br>
    <input type="password" name="Password" required><br>
    <br>
    Confirm Password:
    <input type="password" name="CPassword" required><br>
    <br>
    <input type="submit" value="Register" name="Register">
    </form>

</div>

Also worth mentioning here is the fact that I have another similar form on the same page with a different name to the submit input. So I don't think that is the reason why I am not getting the output. I believe that the Register button is never being set but I wonder why??

suv_12
  • 3
  • 2

2 Answers2

1

Change these

<form action="register.php" method"POST">

To these

<form action="register.php" method="POST">

You forgot about =

Abraham Tugalov
  • 1,902
  • 18
  • 25
0

By default input elements with type="submit" are not sent along via POST requests. Therefore isset($_POST['Register']) always evaluates to false, and your code is not being run hence no output.

One possible solution would be to add an extra hidden input to your form like:

<input type="hidden" name="action" value="submit" />

This will be sent along with the POST request, where you can check isset($_POST['action']) in your PHP and you should get the desired behaviour.

Daniel Waghorn
  • 2,997
  • 2
  • 20
  • 33