Jump to content

Users Login and are Re-Directed to their own Directory.


Andrius

Recommended Posts

Ok here is what I am trying to do and then I will paste what I currently have below.  I want to be able to have my clients login using their user/pass I give them but when they login depending on who they are they will be re-directed to their respective pages.  Like "Club_Vibes" user logs into http://www.getliveevents.com/Club_Vibes/Index.php.  The URL I would like stored in the Membership Database as well.

[code]<?php
/* Program: Login.php
* Desc:    Login program for the Members Only section of the
*          pet store. It provides two options: (1) login
*          using an existing Login Name and (2) enter a new
*          login name. Login Names and passwords are stored
*          in a MySQL database.
*/
                                        # 9
  include("Includes/conn.php"); #10
  switch (@$_GET['do'])                                  #11
  {
    case "login":                                        #13
      $connection = mysql_connect($host, $user,$password) #14
              or die ("Couldn't connect to server.");
      $db = mysql_select_db($database, $connection)
              or die ("Couldn't select database.");      #17

      $sql = "SELECT username FROM getlive_members
              WHERE username='$_POST[fusername]'";      #20
      $result = mysql_query($sql)
                  or die("Couldn't execute query.");      #22
      $num = mysql_num_rows($result);                    #23
      if ($num == 1)  // login name was found            #24
      {
        $sql = "SELECT username FROM getlive_members
                WHERE username='$_POST[fusername]'
                AND password=password('$_POST[fpassword]')";
        $result2 = mysql_query($sql)
                  or die("Couldn't execute query 2.");  #30
        $num2 = mysql_num_rows($result2);
        if ($num2 > 0)  // password is correct          #32
        {
          $_SESSION['auth']="yes";                      #34
          $logname=$_POST['fusername'];
          $_SESSION['logname'] = $logname;              #36
          $today = date("Y-m-d h:i:s");                  #37
          $sql = "INSERT INTO getlive_login (username, logintime)
                  VALUES ('$logname','$today')";
          mysql_query($sql) or die("Can't execute query.");
  echo "<meta http-equiv=\"refresh\" content=\"0;URL=Member_page.php\">";
exit(); 
        }
        else    // password is not correct              #43
        {
          unset($_GET['do']);                            #45
          $message="<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'>The Login Name, '$_POST[fusername]'
                    exists, but you have not entered the
                    correct password! Please try again.<br></font>";
          include("Includes/login_form.inc");                    #49
        }
      }                                                  #51
      elseif ($num == 0)  // login name not found        #52
      { 
        unset($_GET['do']);                              #54
        $message = "<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'>The Login Name you entered does not
                    exist! Please try again.<br></font>";
        include("Includes/login_form.inc");
      }
    break;                                                #59

    case "new":                                          #61
      foreach($_POST as $field => $value)                #62
      {
        if (ereg("(Name)",$field))                        #75
        {
        if (!ereg("^[A-Za-z' -]{1,50}$",$value))
        {
          unset($_GET['do']);
          $message_new = "<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'> $field is not a valid name.
                            Please try again.<br></font>";
          include("/Includes/login_form.inc");
          exit();
        }
        }
        $$field = strip_tags(trim($value));              #86
      } // end foreach
      if (!ereg("^[0-9)(xX -]{7,20}$",$corp_phone))            #96
      {
        unset($_GET['do']);
        $message_new = "<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'> $corp_phone is not a valid phone number.
                        Please try again.<br></font>";
        include("Includes/login_form.inc");
        exit();
      }
      if (!ereg("^.+@.+\\..+$",$corp_email))                  #115
      {
        unset($_GET['do']);
        $message_new = "<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'> $corp_email is not a valid email address.
                        Please try again.<br></font>";
        include("Includes/login_form.inc");
        exit();
      }                                                  #122
      /* check to see if login name already exists */
      $connection = mysql_connect($host,$user,$password) 
                or die ("Couldn't connect to server.");
      $db = mysql_select_db($database, $connection)
                or die ("Couldn't select database.");
      $sql = "SELECT username FROM getlive_members
                WHERE username='$newname'";
      $result = mysql_query($sql)
                or die("Couldn't execute query.");
      $num = mysql_numrows($result);
      if ($num > 0)                                      #133
      {
        unset($_GET['do']);
        $message_new = "<font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'> $newname already used. Select another
                        Member ID. <br></font>";
        include("Includes/login_form.inc");
        exit();
      }
      else                                              #141
      { 
        $today = date("Y-m-d");                          #143
        $sql = "INSERT INTO getlive_members (username,createDate,password,corp_name,corp_phone,corp_email)
VALUES ('$newname','$today',password('$newpass'),'$corp_name','$corp_phone','$corp_email')";
        mysql_query($sql);                              #150
        $_SESSION['auth']="yes";                        #151
        $_SESSION['logname'] = $newname;                #152
        /* send email to new member */                  #153
        $emess = "A new Member Account has been setup. ";
        $emess.= "Your new Member ID and password are: ";
        $emess.= "\n\n\t$newname\n\t$newpass\n\n";
        $emess.= "We appreciate your interest in our Live Shows";
        $emess.= " at GetLiveEvents.com. \n\n";
        $emess.= "If you have any questions or problems,";
        $emess.= " email [email protected]";
        $ehead="From: [email protected]\r\n";    #161
        $subj = "Your new Member Account from GetLiveEvents.com";
        $mailsend=mail("$corp_email","$subj","$emess","$ehead");
        header("Location: New_member.php");              #164
      }
    break;                                              #166

    default:                                            #168
        include("Includes/login_form.inc");
  }
?>[/code]

Thanks a MILLION to anyone that can help me achieve this as right now I'm completely lost in code.

Archived

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

×
×
  • 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.