Note that there are some explanatory texts on larger screens.

plurals
  1. PO(HTML) JavaScript + PHP - $_GET Error
    text
    copied!<p>What I <strong>would like</strong> to achieve:</p> <ul> <li>A index page (<strong>index.html</strong>), which allows the user to register, which runs on JavaScript (<strong>index.js</strong>) to check the fields (<strong>not</strong> mentioned in snippet <strong>index.js</strong>), and then to redirect to a register page (<strong>scripts/register.php</strong>), which then adds the values to the database.</li> </ul> <p>What is <strong>actually happening:</strong></p> <ul> <li>It redirects to the PHP page correctly, however none of the values seem to be transferred when using the <code>$_GET</code> method: I get an empty page.</li> </ul> <p>What am I doing wrong?</p> <p><strong>Code:</strong></p> <hr> <p><strong>index.html (only a snippet)</strong></p> <pre><code>&lt;input name="user" type="text" id="user" size="25" /&gt; &lt;input name="email" type="text" id="email" size="25" /&gt; &lt;input name="pass" type="password" id="pass" size="25" /&gt; &lt;input type="submit" name="signup" id="signup" value="Sign Up" /&gt; &lt;script type = "text/javascript", src = "index.js"&gt; &lt;/script&gt; </code></pre> <hr> <p><strong>index.js (only a snippet)</strong></p> <pre><code>document.getElementById("signup").onclick = signup; var aref = "refcode"; function signup() { window.location.href = 'scripts/register.php?emailaddress=' + document.getElementById("email").value + '&amp;username=' + document.getElementById("user").value + '&amp;password=' + document.getElementById("pass").value + '&amp;aref=' + aref; } </code></pre> <hr> <p><strong>scripts/register.php (only a snippet)</strong></p> <pre><code>&lt;?php echo $_GET['emailaddress']; echo $_GET['username']; echo $_GET['password']; echo $_GET['aref']; ?&gt; </code></pre> <p><strong>EDIT:</strong> I accidentally copied the wrong code for 'scripts/register.php', sorry to all the answers who corrected it for me</p>
 

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