Categories > TinyButStrong general >

Why won't this work

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: DJMoran
Date: 2009-03-06
Time: 23:53

Why won't this work

here is my php file:
<?php
session_start();
include_once('include/tbs_class_php5.php');
include ("include/common.php");
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('template/login.html') ;
$TBS->MergeBlock('flashBlock','mysql','SELECT * FROM `flash_sub` WHERE votes > 9 ORDER BY votescore DESC LIMIT 0, 10');

$showform = 'true' ;
$message = 'You can login here' ;

if ($_SESSION['uid']){
    $message = 'You\'re already logged in, if you wish to log out <a href=\"logout.php\">Click Here!</a>' ;
    $showform = 'false' ;
}else{
    if (!$_POST['submit']){
        $showform = 'true' ;
    }else{
        $user = mss($_POST['username']);
        $pass = $_POST['password'];
            if ($user && $pass){ // Is there a username and pssword
                $sql = "SELECT id FROM `users` WHERE `username`='".$user."'";
                $res = mysql_query($sql) or die(mysql_error());
                if (mysql_num_rows($res) > 0){ //Does the user exist
                    $sql2 ="SELECT id FROM `users` WHERE `username`='".$user."' AND `password`='".md5($pass)."'";
                    $res2 = mysql_query($sql2) or die(mysql_error());
                    if (mysql_num_rows($res2) > 0){ //Does the password match the one on file
                        $row = mysql_fetch_assoc($res2);
                        $_SESSION['uid'] = $row['id'];
                        $showform = 'false' ;
                        $message = 'You have been successfully logged in ' + $row['username'] + '<a href=\"index.php\">Click here</a> to go back to the index page' ;
                    }else{
                        $showform = 'true' ;
                        $message = 'There was a problem with the username and password you supplied. Please try again' ;
                        //Password/Username combination wrong
                    }
                }else{
                    $showform = 'true' ;
                    $message = 'The username you supplied doesn\'t exist. Please try again' ;
                    //Username doesn't exist
                }
            }else{
                $showform = 'true' ;
                $message = 'Please make sure you have filled in both the username and password.' ;
                //need username and password
            }
    }
}

$TBS->Show() ;

?>
and my html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BlackSpring</title>
<link rel="stylesheet" href="./template/main.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="container">
  <div id="header">
      <div id="headtop">&nbsp;</div>
    <div id="headbottom">
      <h1>XAND online</h1>
      <h2>An online community</h2>
    </div>
  </div>
  <div id="menu">
    <ul>
      <li class="current"><a href="index.php">Home</a></li>
      <li><a href="flash.php">Flash</a></li>
      <li><a href="forum.php">Forum</a></li>
      <li><a href="shares.php">Share Trader</a></li>
      <li><a href="mailto: danmoran@blueyonder.co.uk">Contact</a></li>
    </ul>
   
  </div>
  <div id="content">
    <div id="leftcontent">
      <div class="navigation">
        <div class="navhead">Navigation</div>
        <ul class="navmenu">
          <li></li>
        </ul>
      </div>
      <div class="navigation">
        <div class="navhead">Member's Area</div>
        <form class="loginform" method="post" action="login.php">
          <label>User ID</label>
          <input name="username" value="" type="text" size="15" />
          <label>Password</label>
          <input name="password" value="" type="password" size="15" />
          <br />
          <input class="submit" type="submit" value="Login" />
        </form>
      </div>
      <div class="navigation">
          <div class="navhead">Top Flash</div>
        <ul class="ollist">
            <li><a href="./flash.php?sub=[flashBlock.id;block=li]">[flashBlock.title]</a></li>
        </ul>
      </div>
      <div class="navigation">
        <div class="navhead">Ads</div>
        <p> <span class="center">
            <script type="text/javascript"><!--
                google_ad_client = "pub-1781902694704933";
                /* Vertical */
                google_ad_slot = "1556139010";
                google_ad_width = 120;
                google_ad_height = 600;
                //-->
            </script>
            <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
        </span></p>
      </div>
    </div>
   
    <div id="rightcontent">
      [onshow;block=div;when [var.showform]=true]
      <h1 class="posthead">Login</h1>
      <form class="foorm" method="post" action="./login.php">
        <label>User ID</label>
        <input name="username" value="" type="text" size="30" />
        <label>Password</label>
        <input name="password" value="" type="password" size="30" />
        <br />
        <input class="submit" type="submit" value="submit" />
      </form>    
    </div>
    <div id="rightcontent">
      <p class="coode">
        [var.message;block=p] 
      </p>
    </div>
  </div>
  <div class="footclear">&nbsp;</div>
  <div id="footer">
    <h2>&copy; 2006 <a href="http://www.free-css.com/">Your Name</a> | Design by <a href="http://www.flopsoft.co.nr">FlopSoft Inc.</a></h2>
  </div>
</div>
</body>
</html>

Whenever I try this code, the message is always the same ("you can log in here") and the form always shows (even when I provide the data to make it disappear.
By: DJMoran
Date: 2009-03-07
Time: 00:33

Re: Why won't this work

nevermind, the problem was due to the template I am using