Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Form passing values via URL
    text
    copied!<p>I have a login page (local intranet so dont worry about the security issues). This page consists of the following form code :</p> <pre><code>&lt;form action="auth.php" method="get" class="blocklogin"&gt; &lt;tr&gt; &lt;td class="blocklogin" &gt;&lt;div align="left"&gt;Username:&amp;nbsp; &lt;input class="blocklogin" type="text" name="username" id="username" /&gt;&lt;br /&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="blocklogin" &gt;&lt;div align="left"&gt;Password: &amp;nbsp; &lt;input class="blocklogin" type="password" name="password" id="password" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" class="blockloginfoot" title="Login"&gt;&lt;input name="Login" type="submit" value="Login" /&gt;&lt;/td&gt; &lt;/form&gt; </code></pre> <p>Now im trying to pass the username and password via the http link by doing the following : </p> <pre><code>http://localhost/folder/user_login.php?username=user@test&amp;password=test123 </code></pre> <p>But this does not seem to work,its suppose to use the details in the link to login. Am I missing something? Pls help</p> <p>The form action auth.php</p> <pre><code>&lt;?php session_start(); require_once('database.php'); $username = $_GET['username']; $password = $_GET['password']; $sql = "SELECT * FROM access_getaccountswithinfo WHERE username='".$username."' AND password='".$password."'"; $run = mysql_query($sql); $row = mysql_fetch_array($run); if (mysql_num_rows($run) == 1) { $_SESSION['logged_in'] = true; $_SESSION['username'] = $row['username']; $_SESSION['password'] = $row['password']; $_SESSION['packagename'] = $row['packagename']; $_SESSION['creation-date'] = $row['creation-date']; $_SESSION['cap'] = $row['cap']; $_SESSION['total'] = $row['total']; $_SESSION['remainingtopup'] = $row['remainingtopup']; header("location: usage.php"); } else { header("location: user_login.php"); } mysql_close($link); ?&gt; </code></pre> <p>Database code - database.php : </p> <pre><code>&lt;?php $link = mysql_connect('localhost', 'dbase', 'pass123'); if (!$link) { die('Could not connect: ' . mysql_error()); } // make dbase the current db $db_selected = mysql_select_db('dbase', $link); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } ?&gt; </code></pre>
 

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