Jump to content

Welcome table, replaced with error table?


Gregg

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.
[code]<?
/* 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';
    exit();
}

// 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_register('first_name');
        $_SESSION['first_name'] = $first_name;
        session_register('last_name');
        $_SESSION['last_name'] = $last_name;
        session_register('email_address');
        $_SESSION['email_address'] = $email_address;
        session_register('special_user');
        $_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';
}
?>[/code]

Like DEFAULT= Welcome, blablablabla...
Error=thetext.
Link to comment
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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.