0

I'm working on a registration page using an html form, however when I use post it doesn't submit the data. All this code is in the index.php file, so it directs to itself for the form action.

<form action="index.php" method="post" style="align-content: left;text-align: center;padding:10px" id="signForm">
            Company: <input type="text" value="" name="company"><br>
            Email: <input style="margin-top:5px" type="text" value="" name="email"><br>
            Username: <input style="margin-top:5px" type="text" value="" name="username"><br>
            Password: <input style="margin-top:5px" type="password" value="" name="password"><br>
            Verify Password: <input style="margin-top:5px" type="password" value="" name="password2"><br>
            <input style="margin-top:10px" type="submit" value="Submit" name="submitr">
        </form>

And here is the php, which is located above the form on the page.

if(isset($_POST['submitr'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $password2 = $_POST['password2'];
    $email = $_POST['email'];
    $company = $_POST['company'];
    ...
}

I've tried outputting the variables, however they are always blank, and I cannot seem to figure out why. Any help would be greatly appreciated! Thank you!

11
  • Is the form submitted normally, or with javascript? Commented Apr 16, 2017 at 1:19
  • Try enabling error reporting and instead of echo use var_dump() to figure out what the variables contain. Commented Apr 16, 2017 at 1:21
  • @Mike the form is submitted normally, and when I use var_dump($_POST); in my code it outputs array(0) { } both before and after submitting the form. Commented Apr 16, 2017 at 1:25
  • Paste the entire index.php. $_POST shouldn't be empty... Commented Apr 16, 2017 at 1:31
  • I don't see anything here that would cause that behaviour. Are you doing any rewriting with your .htaccess (or equivalent) files? Commented Apr 16, 2017 at 1:31

1 Answer 1

1

Try add a name to the form , also try add the enctype attribute in the form What does enctype='multipart/form-data' mean?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.