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!

Dan F
  • 27
  • 1
  • 5
  • Is the form submitted normally, or with javascript? – Mike Apr 16 '17 at 01:19
  • Try [enabling error reporting](http://stackoverflow.com/a/845025/811240) and instead of `echo` use `var_dump()` to figure out what the variables contain. – Mike Apr 16 '17 at 01: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. – Dan F Apr 16 '17 at 01:25
  • Paste the entire index.php. $_POST shouldn't be empty... – TurtleTread Apr 16 '17 at 01:31
  • I don't see anything here that would cause that behaviour. Are you doing any rewriting with your .htaccess (or equivalent) files? – Mike Apr 16 '17 at 01:31
  • @Mike I'm using AWS for hosting/testing, so as far as I know I don't have access to a the .htaccess file. – Dan F Apr 16 '17 at 01:37
  • @TurtleTread here is the complete file code [link](https://codedump.io/share/NRAHD7Hz8N4i/1/index) – Dan F Apr 16 '17 at 01:37
  • @DanF Works fine for me. – Mike Apr 16 '17 at 01:48
  • Does this help you? http://stackoverflow.com/questions/6923643/php-settings-php-not-receiving-post-data – Mike Apr 16 '17 at 01:51
  • So after looking through the link, I added the part about CONTENT-TYPE, and after looking at phpinfo, the other variables seem to be fine for my setup. I've gotten it to work, however it only works if `phpinfo();` is called, so that's some kind of progress. – Dan F Apr 16 '17 at 02:09
  • Post the global.inc.php file content too please. ofc strip the sensitive data. Did you put session_start() before outputting any content body – TurtleTread Apr 16 '17 at 03:35

1 Answers1

1

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

Community
  • 1
  • 1
Norman
  • 79
  • 3