Ok this is my story. I'm building a simple adminstrative database query page so they can query online. Since it's in the admin section there is a Session ID that gets passed and checked on every page. The problem comes when the form submits. It doesn't query the database because of the session id. How can i fix this?
Here is the Database Query Page:
<?php
/////////////////////////////////////////////////////
//Check the user session //
///////////////////////////////////////////////////
include('../config.php');
$connection = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Connection error!");
mysql_select_db($dbname, $connection);
$query1 = "SELECT SesId FROM Temp WHERE SesId = '$SesId'";
$result = mysql_query($query1)
or die("ERROR #1");
$num_rows = mysql_num_rows($result);
if($num_rows == 0)
{
print("No Access!");
}
else
{
?>
<?php
///////////////////////////////////////////////////
//Stat Database Query Page /
/////////////////////////////////////////////////
if(!isset($query) || empty($query))
{
$query = "select * from pages";
}
$query = stripslashes($query);
$connection = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Connection error!");
mysql_select_db($dbname, $connection);
$result = mysql_query($query)
or die("ERROR #338");
$number_cols = mysql_num_fields($result);
echo "<b>Query: $query</b>";
//layout table hearder
echo "<table border = 1>\n";
echo "<tr align=center>\n";
for ($i = 0; $i<$number_cols; $i++)
{
echo "<th>" . mysql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
//layout table body
while ($row = mysql_fetch_row($result))
{
echo "<tr align=left>\n";
for ($i = 0; $i<$number_cols; $i++)
{
echo "<td>";
if (!isset($row[$i])) //test for null value
{
echo "NULL";
}
else
{
echo $row[$i];
}
echo "</td>";
}
}
echo "</table>";
?>
<form action="<?echo $PHP_SELF, "?SesId=", $SesId ?>" method="get">
<input type="text" name="query" size="50"><br>
<input type="submit">
</form>
<?php
//End Of session checker
}
?>
This is what I was experimenting with:
<form action="<?echo $PHP_SELF, "?SesId=", $SesId ?>" method="get">
<input type="text" name="query" size="50"><br>
<input type="submit">
</form>
could someone tell me how I could pass the SesId and the query to the page?