This is what I have so far...
If someone called up this file, without logging in, I'd like an error to show up...(You must be logged in right now...or something like that.)
Right now, the script does a search in the database for a blank username and returns result...'No tickets'
I don't want it to run, unless they're logged in...
something like
if (sessions = logged in) run ths script.
else display the error.
the correct php coding for this.
Can someone please help me?
<?php
session_start();
$clientuser=$_SESSION['sessuser'];
$clientid=$_SESSION['sessid'];
$clientpass=$_SESSION['sesspass'];
require ("../inc/config.inc.php");
echo "<html><head><title>Support</title><link rel=stylesheet type=text/css href=../templates/$template/styles.css></head><body>";
echo "<table width=500 cellpadding=5 cellspacing=1 border=0><tr class=support_tbtitle>
<td align=center>Priority</td>
<td align=center>ID</td>
<td align=center>Subject</td>
<td align=center>Date</td>
<td align=center>Status</td></tr>";
$sql = "SELECT * FROM support WHERE username='$clientuser'";
$result = mysql_query($sql);
if (!$result)
{
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if(mysql_num_rows($result) == 0)
{
echo "<tr><td colspan=5 class=support_tb>No tickets</td></tr>";
exit;
}
while ($row = mysql_fetch_assoc($result))
{
print "<tr class=support_tb>";
print "<td align=center>" . $row['id'] . "</td>\n";
print "<td align=center><img src=../templates/$template/images/priority_" . $row['priority'] . ".gif></td>\n";
print "<td align=center><a href=\"support.php?ticket=" . $row['id'] . "&view=yes\">" . $row['subject'] . "</a></td>\n";
print "<td align=center>" . $row['opendate'] . "</td>\n";
print "<td align=center><img src=../templates/$template/images/status_" . $row['status'] . ".gif border=0></td>\n";
print "</tr>";
}
?>