Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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!

    Comment


    • #3
      Re: How do I get a &quot;Welcome XXXX&quot; 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.....

      Comment


      • #4
        Re: How do I get a &quot;Welcome XXXX&quot; 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!

        Comment


        • #5
          Re: How do I get a &quot;Welcome XXXX&quot; 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, 06:26 PM. Reason: link doesn't work

          Comment


          • #6
            Re: How do I get a &quot;Welcome XXXX&quot; message after someone logs in?

            The pages are:

            http://www.*****nscottgallery.com/PRIVATE/login.php

            http://www.*****nscottgallery.com/PRIVATE/login2.php which is where the arrays are

            and

            http://www.*****nscottgallery.com/PRIVATE/index.php

            I'm not a BV user so......

            Comment

            Working...
            X