Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    2 login forms 1 sql DB

    PHP Code:
    <?php

     
    if($_SERVER[PHP_SELF]=="/include/loginbox.inc.php")

    {

     
    header("Location: /index.php");

        exit;

    }

    ?>

    <form action="login.php" method="POST">

    <table align="right" cellpadding="1" cellspacing="0">

     <td id="login_tbl">

    <table align="left" cellpadding="1" cellspacing="0">

     <td id="login_cell">

    <td id="login_cell">

     <p><input type="text" name="login" maxlength="30" size="15" style="font-family:lucida grande,sans-serif; font-size:10px;"value=""></p>

    <td id="login_cell">

    <td id="login_cell">

    <p><input type="password" name="password" maxlength="30" size="15" style="font-family:lucida grande,sans-serif; font-size:10px;"></p>

            <td id="login_cell">

     <td id="login_cell">

     <p><input type="submit" value="Login!" style="font-family:Arial,sans-serif; font-size:10px;"></p>

    </table>

    </table>

    </form>

    <? 
    require('poker/includes/gen_inc.php'); 
    $action = (($_GET['action'] != '')? addslashes($_GET['action']) : addslashes($_POST['action']));
    $usr addslashes($_POST['usr']);
    $pwd addslashes($_POST['pwd']);
    $time time();
    $ip $_SERVER['REMOTE_ADDR']; 

    if((
    $action == 'process') && ($usr != '') && ($pwd != '')){
    $GUID randomcode(32);
    $pwdq mysql_fetch_array(mysql_query("select password, banned, approve from ".DB_PLAYERS." where username = '".$usr."' "));
    $orig $pwdq['password'];
    $banned $pwdq['banned'];
    $approve $pwdq['approve'];
    if(
    $approve == 1){
    $msg LOGIN_MSG_APPROVAL;
    }elseif(
    $banned == 1){
    $msg LOGIN_MSG_BANNED;
    }elseif(
    validate_password($pwd,$orig) == true){
    session_start();
    $_SESSION['playername'] = $usr
    $_SESSION['SGUID'] = $GUID;
     
    $result mysql_query("update ".DB_PLAYERS." set ipaddress = '".$ip."', lastlogin = '".$time."' , GUID = '".$GUID."' where username = '".$usr."' ");
    header('Location: lobby.php');
    }else{
    $msg LOGIN_MSG_INVALID;
    }
    }

    ?>
    <html>
    <head>
    <title><? echo TITLE?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="css/poker.css" type="text/css">
    <script language="JavaScript" type="text/JavaScript" src="js/lobby.php"></script>
    </head>


                    
                </table>
              </td>
            </tr>
          </table>
        </td>
        <td width="650" class="fieldsethead" valign="top" height="100%">
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
            
          </table>
          <br>
          <? if($msg != ''){ ?>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              <td colspan="2" align="center" class="smllfont" bgcolor="#660000"> <b> 
                <? echo $msg?>
                </b></td>
            </tr>
          </table>
          <? ?>
          <table border="0" cellspacing="0" cellpadding="0" width="300" align="center">
            <tr> 
              <td><fieldset class="yellowborder"> <legend>&nbsp;
                <? echo BOX_LOGIN?>
                &nbsp;</legend> 
                <form action="login.php" method="post" name="login">
                  <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
                    <tr> 
                      <td width="200" align="right" class="fieldsetheadcontent"> 
                        <p>
                          <? echo LOGIN_USER?>
                          <input type="text" size="12" maxlength="10" name="usr" class="fieldsetheadinputs" />
                        </p>
                        <p>
                          <input type="hidden" name="action" value="process">
                          <? echo LOGIN_PWD?>
                          <input type="password" size="12" maxlength="10" name="pwd" class="fieldsetheadinputs" />
                        </p>
                      </td>
                      <td align="center" width="80" valign="bottom"> 
                        <input type="submit" name="Login" value="<? echo BUTTON_LOGIN?>" class="betbuttons">
                        <br>
                        &nbsp; </td>
                    </tr>
                  </table>
                </form>
                </fieldset></td>
            </tr>
          </table>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              
          </table>
        </td>
      </tr>
    </table>
    <p>&nbsp; </p>
    </body>
    </html>
    One updates <form action="poker/login.php" method="post" name="login"> and the other <form action="login.php" method="POST">
    They both use the same sql DB and i can log in both separately , is ther a way to create just one form and sign in both ?
    Can i use some
    <?php echo $login; ?> <?php echo $pass; ?> <?php echo $_POST['login']; ?> ?
    Thank you
    Last edited by Mihai; 03-15-2010 at 01:22 AM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    You should be able to break it down in a function. Have one form and create two sessions? Or else make the /poker one the same session entity.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php

     
    if($_SERVER[PHP_SELF]=="/include/loginbox.inc.php")

    {

     
    header("Location: /index.php");

        exit;

    }

    ?>


    <? 
    require('poker/includes/gen_inc.php'); 
    $action = (($_GET['action'] != '')? addslashes($_GET['action']) : addslashes($_POST['action']));
    $usr addslashes($_POST['usr']);
    $pwd addslashes($_POST['pwd']);
    $time time();
    $ip $_SERVER['REMOTE_ADDR']; 

    if((
    $action == 'process') && ($usr != '') && ($pwd != '')){
    $GUID randomcode(32);
    $pwdq mysql_fetch_array(mysql_query("select password, banned, approve from ".DB_PLAYERS." where username = '".$usr."' "));
    $orig $pwdq['password'];
    $banned $pwdq['banned'];
    $approve $pwdq['approve'];
    if(
    $approve == 1){
    $msg LOGIN_MSG_APPROVAL;
    }elseif(
    $banned == 1){
    $msg LOGIN_MSG_BANNED;
    }elseif(
    validate_password($pwd,$orig) == true){
    session_start();
    $_SESSION['playername'] = $usr
    $_SESSION['SGUID'] = $GUID;
     
    $result mysql_query("update ".DB_PLAYERS." set ipaddress = '".$ip."', lastlogin = '".$time."' , GUID = '".$GUID."' where username = '".$usr."' ");
    header('Location: lobby.php');
    }else{
    $msg LOGIN_MSG_INVALID;
    }
    }

    ?>
    <html>
    <head>
    <title><? echo TITLE?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="css/poker.css" type="text/css">
    <script language="JavaScript" type="text/JavaScript" src="js/lobby.php"></script>
    </head>


                    
                </table>
              </td>
            </tr>
          </table>
        </td>
        <td width="650" class="fieldsethead" valign="top" height="100%">
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
            
          </table>
          <br>
          <? if($msg != ''){ ?>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              <td colspan="2" align="center" class="smllfont" bgcolor="#660000"> <b> 
                <? echo $msg?>
                </b></td>
            </tr>
          </table>
          <? ?>
          <table border="0" cellspacing="0" cellpadding="0" width="300" align="center">
            <tr> 
              <td><fieldset class="yellowborder"> <legend>&nbsp;
                <? echo BOX_LOGIN?>
                &nbsp;</legend> 
                <form action="poker/login.php" method="post" name="login">
                  <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
                    <tr> 
                      <td width="200" align="right" class="fieldsetheadcontent"> 
                        <p>
                          <? echo LOGIN_USER?>
                          <input type="text" size="12" maxlength="10" name="usr" class="fieldsetheadinputs" />
                        </p>
                        <p>
                          <input type="hidden" name="action" value="process">
                          <? echo LOGIN_PWD?>
                          <input type="password" size="12" maxlength="10" name="pwd" class="fieldsetheadinputs" />
                        </p>
                      </td>
                      <td align="center" width="80" valign="bottom"> 
                        <input type="submit" name="Login" value="<? echo BUTTON_LOGIN?>" class="betbuttons">
                        <br>
                        &nbsp; </td>
                    </tr>
                  </table>
                </form>
                </fieldset></td>
            </tr>
          </table>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              

    <form action="login.php" method="POST" "value="$pwd";"value="$usr">



          </table>
        </td>
      </tr>
    </table>
    <p>&nbsp; </p>
    </body>
    </html>
    will this do ? <form action="login.php" method="POST" "value="$pwd";"value="$usr">?


    <form action="login.php" method="POST" name="login2">

    '<input type="text" name="<?php echo $_REQUEST["usr"]; ?>">
    <input type="password" name="<?php echo $_REQUEST["pwd"]; ?>" ???
    Last edited by Mihai; 03-15-2010 at 02:35 AM.

  • #4
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Unhappy

    can someone please help me out ?

  • #5
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    both log in scripts.
    PHP Code:
    <?php

    // File ID: login.php (user log in routine)
    session_start();

    include(
    "require/config.php");
    require(
    "require/membership.php");
    require(
    "./require/functions.php");

    $connection = @mysql_connect("$db_host""$db_user""$db_pass") or die("Couldn't connect.");
    $db = @mysql_select_db($db_name$connection) or die("Couldn't select database.");

    $sql="SELECT * FROM $tbl_members
    WHERE login = "
    .quote_smart($_POST[login])." AND password = ".quote_smart($_POST[password])."";

    $result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " $query "<br />\nError: (" mysql_errno() . ") " mysql_error());

    $num=mysql_num_rows($result);
    while (
    $row mysql_fetch_array($result)) {
    $enabled $row['enabled'];
    $member_id $row['member_id'];
    $password $row['password'];
    $email $row['email'];
    $displayname $row['displayname'];
    $newsletter $row['newsletter'];
    $ipaddr $row['ipaddr'];
    }
    if(
    $num >0) {

    if(
    $enabled == "yes") {

    $valid_user $_POST['login'];
    session_register("valid_user");
    session_register("enabled");
    session_register("member_id");
    session_register("password");
    session_register("email");
    session_register("displayname");
    session_register("newsletter");
    session_register("ipaddr");

    if(isset(
    $_SERVER['HTTP_REFERER'])) {
    $ref $_SERVER['HTTP_REFERER'];
    if(
    $ref == "$siteurl/login.php") {
    $ref "index.php";
    }
    } else {
    $ref "index.php";
    }
    include(
    "redirect.php");
    exit;
    }
    }
    if(
    $num ==0) {
    $error "Invalid username password combination.";
    }

    if(
    $enabled == "no") {
    $error "Your account is not enabled.";
    }
    if(!
    $error) {
    $error "Unknown login error.";
    }

    $content "./include/login.inc.php";
    $menu="include/menu_u.inc.php";
    $page_title="Login Form";

    global 
    $content$menu$page_title;

    include(
    "include/header.inc.php");
    include(
    "include/body.inc.php");
    include(
    "include/footer.inc.php");
    ?>
    and
    PHP Code:
    <? 
    require('includes/gen_inc.php'); 
    $action = (($_GET['action'] != '')? addslashes($_GET['action']) : addslashes($_POST['action']));
    $usr addslashes($_POST['usr']);
    $pwd addslashes($_POST['pwd']);
    $time time();
    $ip $_SERVER['REMOTE_ADDR']; 

    if((
    $action == 'process') && ($usr != '') && ($pwd != '')){
    $GUID randomcode(32);
    $pwdq mysql_fetch_array(mysql_query("select password, banned, approve from ".DB_PLAYERS." where username = '".$usr."' "));
    $orig $pwdq['password'];
    $banned $pwdq['banned'];
    $approve $pwdq['approve'];
    if(
    $approve == 1){
    $msg LOGIN_MSG_APPROVAL;
    }elseif(
    $banned == 1){
    $msg LOGIN_MSG_BANNED;
    }elseif(
    validate_password($pwd,$orig) == true){
    session_start();
    $_SESSION['playername'] = $usr
    $_SESSION['SGUID'] = $GUID;
     
    $result mysql_query("update ".DB_PLAYERS." set ipaddress = '".$ip."', lastlogin = '".$time."' , GUID = '".$GUID."' where username = '".$usr."' ");
    header('Location: lobby.php');
    }else{
    $msg LOGIN_MSG_INVALID;
    }
    }

    ?>
    <html>
    <head>
    <title><? echo TITLE?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="css/poker.css" type="text/css">
    <script language="JavaScript" type="text/JavaScript" src="js/lobby.php"></script>
    </head>

    <body bgcolor="#000000" text="#CCCCCC" >
    <table width="772" border="0" cellspacing="0" cellpadding="2" align="center" bgcolor="#1B1B1B">
         <td width="650" class="fieldsethead" valign="top" height="100%">
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
            <tr> 
              <td bgcolor="#333333"><b><font size="3"><i><? echo LOGIN?></i> </font></b></td>
            </tr>
          </table>
          <br>
          <? if($msg != ''){ ?>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              <td colspan="2" align="center" class="smllfont" bgcolor="#660000"> <b> 
                <? echo $msg?>
                </b></td>
            </tr>
          </table>
          <? ?>
          <table border="0" cellspacing="0" cellpadding="0" width="300" align="center">
            <tr> 
              <td><fieldset class="yellowborder"> <legend>&nbsp;
                <? echo BOX_LOGIN?>
                &nbsp;</legend> 
                <form action="login.php" method="post" name="login">
                  <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
                    <tr> 
                      <td width="200" align="right" class="fieldsetheadcontent"> 
                        <p>
                          <? echo LOGIN_USER?>
                          <input type="text" size="12" maxlength="10" name="usr" class="fieldsetheadinputs" />
                        </p>
                        <p>
                          <input type="hidden" name="action" value="process">
                          <? echo LOGIN_PWD?>
                          <input type="password" size="12" maxlength="10" name="pwd" class="fieldsetheadinputs" />
                        </p>
                      </td>
                      <td align="center" width="80" valign="bottom"> 
                        <input type="submit" name="Login" value="<? echo BUTTON_LOGIN?>" class="betbuttons">
                        <br>
                        &nbsp; </td>
                    </tr>
                  </table>
                </form>
                </fieldset></td>
            </tr>
          </table>
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr> 
              <td colspan="2" align="right" class="fieldsetheadlink"><a href="create.php" target="_self" class="fieldsetheadlink"><i>
                <? echo LOGIN_NEW_PLAYER?>
                </i></a></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    <p>&nbsp; </p>
    </body>
    </html>
    Can some one please help me create same login form out of this with same session for both scripts ?

    Thank you

  • #6
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Unhappy

    Can someone please help me out here
    Last edited by Mihai; 03-16-2010 at 08:57 PM.

  • #7
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Can you say in words what are you trying to do?? You want to use those 2 php login scripts, but choose which to execute from 2 buttons? Also you have to start same session otherwise..? And what about your databases? What information for which variables you are using??

  • #8
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    I'm new to php , but i'm trying to add some more functionality to a script in to another one , the DB looks like this :

    CREATE TABLE IF NOT EXISTS `members` (
    `member_id` mediumint(8) unsigned zerofill NOT NULL auto_increment,
    `login` varchar(20) NOT NULL default '',
    `enabled` enum('yes','no') NOT NULL default 'yes',
    `password` varchar(20) NOT NULL default '',
    `email` varchar(150) NOT NULL default '',
    `displayname` varchar(25) NOT NULL default '',
    `newsletter` enum('yes','no') NOT NULL default 'yes',
    `ipaddr` varchar(16) NOT NULL default '',
    `avatar` varchar(80) default '',
    `datecreated` int(35) default '0',
    `lastlogin` int(35) default '0',
    `sessname` varchar(32) default '',
    `approve` tinyint(1) default '0',
    `lastmove` int(35) default '0',
    `waitimer` int(35) default '0',
    `code` varchar(16) default '',
    `GUID` varchar(32) default '',
    `vID` int(15) default '0',
    `gID` int(15) default '0',
    `timetag` int(30) default '0',
    PRIMARY KEY (`member_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

    For one script
    And for second one :
    CREATE TABLE IF NOT EXISTS `players` (
    `ID` int(11) NOT NULL auto_increment,
    `username` varchar(12) default '',
    `email` varchar(70) default '',
    `password` varchar(40) default '',
    `avatar` varchar(80) default '',
    `datecreated` int(35) default '0',
    `lastlogin` int(35) default '0',
    `ipaddress` varchar(20) default '',
    `sessname` varchar(32) default '',
    `banned` tinyint(1) default '0',
    `approve` tinyint(1) default '0',
    `lastmove` int(35) default '0',
    `waitimer` int(35) default '0',
    `code` varchar(16) default '',
    `GUID` varchar(32) default '',
    `vID` int(15) default '0',
    `gID` int(15) default '0',
    `timetag` int(30) default '0',
    PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=90 ;

    My first log in script looks like :
    PHP Code:
    <?php 

    // File ID: login.php (user log in routine) 
    session_start(); 

    include(
    "require/config.php"); 
    require(
    "require/membership.php"); 
    require(
    "./require/functions.php"); 

    $connection = @mysql_connect("$db_host""$db_user""$db_pass") or die("Couldn't connect."); 
    $db = @mysql_select_db($db_name$connection) or die("Couldn't select database."); 

    $sql="SELECT * FROM $tbl_members 
    WHERE login = "
    .quote_smart($_POST[login])." AND password = ".quote_smart($_POST[password]).""

    $result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " $query "<br />\nError: (" mysql_errno() . ") " mysql_error()); 

    $num=mysql_num_rows($result); 
    while (
    $row mysql_fetch_array($result)) { 
    $enabled $row['enabled']; 
    $member_id $row['member_id']; 
    $password $row['password']; 
    $email $row['email']; 
    $displayname $row['displayname']; 
    $newsletter $row['newsletter']; 
    $ipaddr $row['ipaddr']; 

    if(
    $num >0) { 

    if(
    $enabled == "yes") { 

    $valid_user $_POST['login']; 
    session_register("valid_user"); 
    session_register("enabled"); 
    session_register("member_id"); 
    session_register("password"); 
    session_register("email"); 
    session_register("displayname"); 
    session_register("newsletter"); 
    session_register("ipaddr"); 

    if(isset(
    $_SERVER['HTTP_REFERER'])) { 
    $ref $_SERVER['HTTP_REFERER']; 
    if(
    $ref == "$siteurl/login.php") { 
    $ref "index.php"

    } else { 
    $ref "index.php"

    include(
    "redirect.php"); 
    exit; 


    if(
    $num ==0) { 
    $error "Invalid username password combination."


    if(
    $enabled == "no") { 
    $error "Your account is not enabled."

    if(!
    $error) { 
    $error "Unknown login error."


    $content "./include/login.inc.php"
    $menu="include/menu_u.inc.php"
    $page_title="Login Form"

    global 
    $content$menu$page_title

    include(
    "include/header.inc.php"); 
    include(
    "include/body.inc.php"); 
    include(
    "include/footer.inc.php"); 
    ?> 
    and
    And second one:

    PHP Code:
    <?  
    require('includes/gen_inc.php');  
    $action = (($_GET['action'] != '')? addslashes($_GET['action']) : addslashes($_POST['action'])); 
    $usr addslashes($_POST['usr']); 
    $pwd addslashes($_POST['pwd']); 
    $time time(); 
    $ip $_SERVER['REMOTE_ADDR'];  

    if((
    $action == 'process') && ($usr != '') && ($pwd != '')){ 
    $GUID randomcode(32); 
    $pwdq mysql_fetch_array(mysql_query("select password, banned, approve from ".DB_PLAYERS." where username = '".$usr."' ")); 
    $orig $pwdq['password']; 
    $banned $pwdq['banned']; 
    $approve $pwdq['approve']; 
    if(
    $approve == 1){ 
    $msg LOGIN_MSG_APPROVAL
    }elseif(
    $banned == 1){ 
    $msg LOGIN_MSG_BANNED
    }elseif(
    validate_password($pwd,$orig) == true){ 
    session_start(); 
    $_SESSION['playername'] = $usr;  
    $_SESSION['SGUID'] = $GUID
     
    $result mysql_query("update ".DB_PLAYERS." set ipaddress = '".$ip."', lastlogin = '".$time."' , GUID = '".$GUID."' where username = '".$usr."' "); 
    header('Location: lobby.php'); 
    }else{ 
    $msg LOGIN_MSG_INVALID



    ?> 
    <html> 
    <head> 
    <title><? echo TITLE?></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
    <link rel="stylesheet" href="css/poker.css" type="text/css"> 
    <script language="JavaScript" type="text/JavaScript" src="js/lobby.php"></script> 
    </head> 

    <body bgcolor="#000000" text="#CCCCCC" > 
    <table width="772" border="0" cellspacing="0" cellpadding="2" align="center" bgcolor="#1B1B1B"> 
         <td width="650" class="fieldsethead" valign="top" height="100%"> 
          <table width="100%" border="0" cellspacing="0" cellpadding="3"> 
            <tr>  
              <td bgcolor="#333333"><b><font size="3"><i><? echo LOGIN?></i> </font></b></td> 
            </tr> 
          </table> 
          <br> 
          <? if($msg != ''){ ?> 
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center"> 
            <tr>  
              <td colspan="2" align="center" class="smllfont" bgcolor="#660000"> <b>  
                <? echo $msg?> 
                </b></td> 
            </tr> 
          </table> 
          <? ?> 
          <table border="0" cellspacing="0" cellpadding="0" width="300" align="center"> 
            <tr>  
              <td><fieldset class="yellowborder"> <legend>&nbsp; 
                <? echo BOX_LOGIN?> 
                &nbsp;</legend>  
                <form action="login.php" method="post" name="login"> 
                  <table width="300" border="0" cellspacing="0" cellpadding="5" align="center"> 
                    <tr>  
                      <td width="200" align="right" class="fieldsetheadcontent">  
                        <p> 
                          <? echo LOGIN_USER?> 
                          <input type="text" size="12" maxlength="10" name="usr" class="fieldsetheadinputs" /> 
                        </p> 
                        <p> 
                          <input type="hidden" name="action" value="process"> 
                          <? echo LOGIN_PWD?> 
                          <input type="password" size="12" maxlength="10" name="pwd" class="fieldsetheadinputs" /> 
                        </p> 
                      </td> 
                      <td align="center" width="80" valign="bottom">  
                        <input type="submit" name="Login" value="<? echo BUTTON_LOGIN?>" class="betbuttons"> 
                        <br> 
                        &nbsp; </td> 
                    </tr> 
                  </table> 
                </form> 
                </fieldset></td> 
            </tr> 
          </table> 
          <table width="300" border="0" cellspacing="0" cellpadding="5" align="center"> 
            <tr>  
              <td colspan="2" align="right" class="fieldsetheadlink"><a href="create.php" target="_self" class="fieldsetheadlink"><i> 
                <? echo LOGIN_NEW_PLAYER?> 
                </i></a></td> 
            </tr> 
          </table> 
        </td> 
      </tr> 
    </table> 
    <p>&nbsp; </p> 
    </body> 
    </html>
    So my question is :
    Can i re-create one of the log in script to connect on both ? Something like if PRIMARY KEY (`member_id`) =1 and PRIMARY KEY (`ID`) =1 then it is the same user.
    Like i just said i dont know a lot about php.
    If i log in with 'credentials' from one part of the log in "members" and have the same username and pass on 'players" and the ID nr is the same does it 'recognize' the same user ? I know i will have to re-create the registration process to.
    Thank you for your consideration.

    Mihai
    Last edited by Mihai; 03-16-2010 at 09:27 PM.

  • #9
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Ofcourse it is possible...

    The easiest way to do this is to put everything in one page...
    And do some changes...

    Here's what I have got
    PHP Code:
    <?php  

    // File ID: login.php (user log in routine)  
    session_start();  

    include(
    "require/config.php");  
    require(
    "require/membership.php");  
    require(
    "./require/functions.php");  

    $connection = @mysql_connect("$db_host""$db_user""$db_pass") or die("Couldn't connect.");  
    $db = @mysql_select_db($db_name$connection) or die("Couldn't select database.");  

    $sql="SELECT * FROM $tbl_members  
    WHERE login = "
    .quote_smart($_POST[login])." AND password = ".quote_smart($_POST[password])."";  

    $result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " $query "<br />\nError: (" mysql_errno() . ") " mysql_error());  

    $num=mysql_num_rows($result);  
    while (
    $row mysql_fetch_array($result)) {  
    $enabled $row['enabled'];  
    $member_id $row['member_id'];  
    $password $row['password'];  
    $email $row['email'];  
    $displayname $row['displayname'];  
    $newsletter $row['newsletter'];  
    $ipaddr $row['ipaddr'];  
    }  
    if(
    $num >0) {

    require(
    'includes/gen_inc.php');   
    $action = (($_GET['action'] != '')? addslashes($_GET['action']) : addslashes($_POST['action']));  
    $usr addslashes($_POST['login']);  
    $pwd addslashes($_POST['password']);  
    $time time();  
    $ip $_SERVER['REMOTE_ADDR'];   

    if((
    $action == 'process') && ($usr != '') && ($pwd != '')){  
    $GUID randomcode(32);  
    $pwdq mysql_fetch_array(mysql_query("select password, banned, approve from ".DB_PLAYERS." where username = '".$usr."' "));  
    $orig $pwdq['password'];  
    $banned $pwdq['banned'];  
    $approve $pwdq['approve'];  
    if(
    $approve == 1){  
    $msg LOGIN_MSG_APPROVAL;  
    }elseif(
    $banned == 1){  
    $msg LOGIN_MSG_BANNED;  
    }elseif(
    validate_password($pwd,$orig) == true){  
    session_start();  
    $_SESSION['playername'] = $usr;   
    $_SESSION['SGUID'] = $GUID;  
     
    $result mysql_query("update ".DB_PLAYERS." set ipaddress = '".$ip."', lastlogin = '".$time."' , GUID = '".$GUID."' where username = '".$usr."' ");    
    }else{  
    $msg LOGIN_MSG_INVALID;  
    }  

      
    if(
    $enabled == "yes") {  

    $valid_user $_POST['login'];  
    session_register("valid_user");  
    session_register("enabled");  
    session_register("member_id");  
    session_register("password");  
    session_register("email");  
    session_register("displayname");  
    session_register("newsletter");  
    session_register("ipaddr");  

    if(isset(
    $_SERVER['HTTP_REFERER'])) {  
    $ref $_SERVER['HTTP_REFERER'];  
    if(
    $ref == "$siteurl/login.php") {  
    $ref "index.php";  
    }  
    } else {  
    $ref "index.php";  
    }  
    include(
    "redirect.php");  
    exit;  
    }  
    }  
    if(
    $num ==0) {  
    $error "Invalid username password combination.";  
    }  

    if(
    $enabled == "no") {  
    $error "Your account is not enabled.";  
    }  
    if(!
    $error) {  
    $error "Unknown login error.";  
    }  

    $content "./include/login.inc.php";  
    $menu="include/menu_u.inc.php";  
    $page_title="Login Form";  

    global 
    $content$menu$page_title;  

    include(
    "include/header.inc.php");  
    include(
    "include/body.inc.php");  
    include(
    "include/footer.inc.php");  
    ?>
    I am not sure if it is working Good luck

  • #10
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    you created those scripts??

  • #11
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    It only logs me in table players but i'm not sign in members.
    Both script are not mine , one of them ( phpprofiles i got it 2 years ago for 25 $ and the second i got it as open source ).

  • #12
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    hmm, what about $action variable? why do you use this? Because it GET's action from somewhere... I can't see from where

    have you got any message like: LOGIN_MSG_APPROVAL; LOGIN_MSG_BANNED; OR LOGIN_MSG_INVALID; ???
    }
    Last edited by auriaks; 03-16-2010 at 10:30 PM.

  • #13
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    no error message and i have same user and pass on both sql rows and i am only logged in one and if i want to navigate on second page ( second script ) i am not logged in.

    Can i verifie somehow if i am logged in both ? like SELECT * FROM $tbl_members
    WHERE login = ...
    from both rows to see if i am the same user on both ?

  • #14
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    if you haven't seen message, that means that this IF:

    PHP Code:
    if(($action == 'process') && ($usr != '') && ($pwd != '')){ 
    isn't working at all.

    Hmm, Can you explain what is this action? or you don't know?

  • #15
    Regular Coder
    Join Date
    Feb 2010
    Posts
    209
    Thanks
    15
    Thanked 2 Times in 2 Posts
    try to leave just this:

    PHP Code:
    if(($usr != '') && ($pwd != '')){ 
    and try again


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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