Please see the code below:
<html>
<style type="text/css">
... some code ...
</style>
</head>
<?php
$db = pg_connect("****") or die("Unable to connect to the database.");
$sql = "SELECT * FROM reg_users where username like '$username' AND passwd like '$passwd'";
$result = pg_query($sql);
if (pg_num_rows($result) == 0){
?>
<H2 class="style6">Access denied</H2>
<span class="style6"><BR>
Authorization failed.
</span>
<?php
exit;}
else{
$currentdate = getdate(time());
$time = $currentdate["hours"].":".$currentdate["minutes"];
$date = $currentdate["mday"]." ".$currentdate["month"]." ".$currentdate["year"];
$firstname = pg_fetch_result($result,firstname);
?>
... some tables ...
W</font></span></font>elcome <?php echo $firstname?>!<br>
... some other stuff ...
<td width="108" height="52" align="left" valign="bottom"><form method="POST" action=''>
<input type="SUBMIT" class="style19" name="use_button" value="Use Rheometer"></form>
<?php
if (isset($_POST['use_button'])){
$add_session = "INSERT INTO sessions (username, date, time)
VALUES ('".$username."', '".$date."', '".$time."')";
$session_result = pg_query($add_session);
$add_log2 = "INSERT INTO web_log (username, action, date, time)
VALUES ('".$username."', '".RH_TST."', '".$date."', '".$time."')";
$session_result2 = pg_query($add_log2);}?>
</td>
... some more stuff ...
<p> </p>
<?php
}
?>
</html>
That is the actual code that I am working on. I have tried to diagnose it and concluded that this piece of code causes the problem:
if (pg_num_rows($result) == 0){
?>
<H2 class="style6">Access denied</H2>
<span class="style6"><BR>
Authorization failed.
</span>
<?php
exit;}
To remind you, the problem is that when the button "Use Rheometer" is pressed, the PHP command following it doesn't execute. Also there's login page which, if username/pass is correct, redirects the user to the above page. $username and $passwd are defined as global sessions in the logn page.
Any help on how to make this work is greatly appreciated.
P.S> I included every single PHP part of the entire code, just in case. But took out the HTML's and JS and CSS etc.