Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Incorrect POST data being sent through a form upon echo?
    primarykey
    data
    text
    <p>I'm writing a simple registration form to add users to a database. The code is below.</p> <pre><code>&lt;?php include 'header.php'; $tag = randomString(); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Register an Account&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;b&gt;Register an account&lt;/b&gt;&lt;br&gt;&lt;br&gt; &lt;form method="post" action="add_user.php?tag=&lt;?echo $tag;?&gt;"&gt; Username: &lt;br&gt;&lt;input type="text" name="username" size=25/&gt;&lt;br /&gt;&lt;br&gt; Password: &lt;br&gt;&lt;input type="password" name="password" size=25/&gt;&lt;br /&gt;&lt;br&gt; Confirm Password: &lt;br&gt;&lt;input type="password" name="confirm" size=25/&gt;&lt;br /&gt;&lt;br&gt; Email Address: &lt;br&gt;&lt;input type="text" name="email" size=25/&gt;&lt;br /&gt;&lt;br&gt;&lt;br&gt; Additional Info: &lt;br&gt;&lt;input type="text" name="info" size=50/&gt;&lt;br&gt; &lt;input type="submit" name="Submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The form seems to work fine. However, when I attempt to read this post data on the next page, some entries are correct, and others are not, even when all entries are filled. For example:</p> <pre><code>echo mysql_real_escape_string(htmlentities($_POST['username'])); --&gt; outputs what was in the info field echo mysql_real_escape_string(htmlentities($_POST['password'])); --&gt; output is what was entered in "confirm" echo mysql_real_escape_string(htmlentities($_POST['confirm'])); --&gt; no output echo mysql_real_escape_string(htmlentities($_POST['email'])); --&gt; email is outputted, this is correct. echo mysql_real_escape_string(htmlentities($_POST['info'])); --&gt; No output. </code></pre> <p>Very confused as to why this is happening, I've written many forms with no such problems.</p> <p>EDIT: Here's the var_dump (data entered: username, Pass1, Pass2, email@address.com, and info in the proper order):</p> <pre><code>array(4) { ["username"]=&gt; string(4) "info" ["password"]=&gt; string(5) "Pass2" ["email"]=&gt; string(17) "email@address.com" ["Submit"]=&gt; string(6) "Submit" } </code></pre> <p>EDIT2: Added entire page's code</p> <p><b>add_user.php</b> (Not finished-- the issue came up when I was trying to compare the two passwords. That never evaluated as true, mainly because I wasn't comparing what I thought I was)</p> <pre><code>&lt;?php //var_dump($_POST); echo mysql_real_escape_string(htmlentities($_POST['username'])); echo "&lt;br&gt;"; echo mysql_real_escape_string(htmlentities($_POST['password'])); echo "&lt;br&gt;"; echo mysql_real_escape_string(htmlentities($_POST['confirm'])); echo "&lt;br&gt;"; echo mysql_real_escape_string(htmlentities($_POST['email'])); echo "&lt;br&gt;"; echo mysql_real_escape_string(htmlentities($_POST['info'])); echo "&lt;br&gt;"; if ($_POST['password'] != $_POST['confirm']) { die("Passwords do not match. Please go back and try again."); } $tag = $_GET['tag']; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload