Jump to content


This topic is now archived and is closed to further replies.


Welcome table, replaced with error table?

Recommended Posts

Ok, in the login form i would like to make it so when they hit the page it has a table above the form saying Welcome... blablabla.
And if they submit the for and get an error it replaces the welcome message with the error message in the center of that table instead of allways top left lol!

I want to know how to ad the welcome message and how to get it to show up where i want it.
/* Check User Script */
session_start();  // Start Session

include 'db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];

if((!$username) || (!$password)){
    echo "Welcome, please login!<br />";
    include 'login_form.html';

// Convert password to md5 hash
$password = md5($password);

// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);

if($login_check > 0){
    while($row = mysql_fetch_array($sql)){
    foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
        // Register some session variables!
        $_SESSION['first_name'] = $first_name;
        $_SESSION['last_name'] = $last_name;
        $_SESSION['email_address'] = $email_address;
        $_SESSION['user_level'] = $user_level;
        mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
        header("Location: login_success.php");
} else {
    echo "You could not be logged in, either the Username/Password do not match,<br>
        our records.. Or you have not Validated your Membership with us yet!<br />";
    include 'login_form.html';

Like DEFAULT= Welcome, blablablabla...

Share this post

Link to post
Share on other sites
OOP Templating engines...  try using one called FastTemplate -- but if you get that one you want the one that was written for php3.. you have to go in and rename one of the functions as they try to recall it twice.. but ya just rename the second one by putting a 1 at the end... 

Another option would be to use Smarty.. http://www.php.net/smarty

I think that is the url to smarty.. its a templating engine we use at work.. only problem is youve got to get it on your server..  FastTemplate is easier to impliment as it is only 1 file..  From that you can do just about anything you want...

Share this post

Link to post
Share on other sites
What  i ment was just a simple php sniplet i could place anywhere so it wont move and distort the template.
Like this:
<? echo $Message or print;?> something to that afect.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.