Results 1 to 6 of 6

Thread: How do I get a "Welcome XXXX" message after someone logs in?
      
   

  1. #1
    paulcon is offline Private
    Join Date
    Jun 2011
    Posts
    4

    Default How do I get a "Welcome XXXX" message after someone logs in?

    Hi there,

    I'm creating a Private Gallery for our website and have successfully implemented NBOP's PHP code from 2006. (http://www.vodahost.com/vodatalk/blu...ple-users.html). Love it!

    However, I would like to have a "Welcome, XXXX" message appear on the index page after the viewer has successfully logged in. I have no problem getting it to post the Username but how do I get the person's real name to appear? I tried creating a third array with various names, but I don't know how to make the PHP on the index page link to the real name array.

    Thanks!!!!

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: How do I get a "Welcome XXXX" message after someone logs in?

    Add the text:

    Welcome '.$name.'

    in your page (which MUST be .php)

    Right click it, select HTML and add the following codes:

    In the Before Tag:

    <?php echo '


    In the After tag:

    ';?>




    Then add in Start of Page, this code

    <?php
    session_start();
    if($_SESSION['username'] == ""){
    $name = "guest";
    }
    else {
    $name = $_SESSION['username'];
    }
    ?>
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    paulcon is offline Private
    Join Date
    Jun 2011
    Posts
    4

    Default Re: How do I get a "Welcome XXXX" message after someone logs in?

    Thanks, Navaldesign....

    It almost works.....

    This is the PHP code on login2.php:

    <?php
    $usernames = array("user1", "user2", "user3", "superman");
    $passwords = array("pass1", "pass2", "pass3", "supermans password");
    $names = array("Paul", "Bob", "John", "Neil"); // I added this to match the names with the login information
    $page = "index.php";



    for($i=0;$i<count($usernames);$i++){
    $logindata[$usernames[$i]]=$passwords[$i];
    }
    if($logindata[$_POST["username"]]==$_POST["password"]){
    session_start();
    $_SESSION["username"]=$_POST["username"];
    header('Location: '.$page);
    exit;
    }else{
    header('Location: login.php?wrong=1');
    exit;
    }
    ?>


    On the page I want the welcome "person name" to show up on, I've inserted at your instruction:

    <?php require("login3.php"); ?>
    <?php session_start();
    if($_SESSION['username'] == ""){
    $name = "guest";
    }
    else {
    $name = $_SESSION['username'];
    }
    ?>

    in lines 1 - 9 of the document, and

    Welcome, <?php echo'.$name.'; ?>

    in the part of the table I want the welcome message to appear.

    What I get though, is "Welcome, .$Name." instead of the person's name from the array declared on login2.php

    What am I doing wrong?

    Thanks in advance.....

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: How do I get a "Welcome XXXX" message after someone logs in?

    First, please note that $name and $Name are NOT the same thing.

    Second, I need to see the page that contains the message. A link pls ?
    However from the type of error, you have probably NOT added the codes I posted in the Before and After tags of the text.

    If the text is within a table, then probably BV converts the tags to the equivalent HTML tags.

    Please try placing the text self standing (not within a table) and test. If it works, the problem is the fact that you have used it within a table. In that case you will need to modify the code.

    But why aren't you using the BV built in Login script ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  5. #5
    paulcon is offline Private
    Join Date
    Jun 2011
    Posts
    4

    Default Re: How do I get a "Welcome XXXX" message after someone logs in?

    This is the login page - it works perfectly!



    The usernames and passwords are stored in:

    , which is as follows:

    <?php
    $usernames = array("user1", "user2", "user3", "superman");
    $passwords = array("pass1", "pass2", "pass3", "supermans password");
    $names = array("Paul", "Bob", "John", "Neil"); // this is the array with the peoples' real names
    $page = "index.php";



    for($i=0;$i<count($usernames);$i++){
    $logindata[$usernames[$i]]=$passwords[$i];
    }
    if($logindata[$_POST["username"]]==$_POST["password"]){
    session_start();
    $_SESSION["username"]=$_POST["username"];
    header('Location: '.$page);
    exit;
    }else{
    header('Location: login.php?wrong=1');
    exit;
    }
    ?>

    After login you go to:



    where you can see the welcome message
    Last edited by paulcon; 06-04-2011 at 06:26 PM. Reason: link doesn't work

  6. #6
    paulcon is offline Private
    Join Date
    Jun 2011
    Posts
    4

    Default Re: How do I get a "Welcome XXXX" message after someone logs in?


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49