boemboem Posted February 24, 2009 Share Posted February 24, 2009 Hello all, Let me first explain something: I have two websites. 1 - main website, located here www.coldcharlie.nl 2 - ladder/cup website located here http://ladders.coldcharlie.nl What I want is that the users of the main website dont have to register again for the ladder/cup website. This should be possible, but I don't know how. My question, is here somebody who can take a look at it? this is the login check og the main website: $ws_pwd=md5($_POST['pwd']); include("_mysql.php"); include("_settings.php"); $ws_user = $_POST['ws_user']; $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user'"); $anz = mysql_num_rows($check); if($anz) { $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user' AND activated='1'"); if(mysql_num_rows($check)) { $ds=mysql_fetch_array($check); // check password $login = 0; if($ws_pwd == $ds[password]) { //session session_name('ws_session'); session_start(); $_SESSION['ws_auth'] = $ds['userID'].":".$ws_pwd; $_SESSION['ws_lastlogin'] = $ds[lastlogin]; $_SESSION['referer'] = $_SERVER['HTTP_REFERER']; //cookie setcookie("ws_auth", $ds['userID'].":".$ws_pwd, time()+($sessionduration*60*60)); $login = 1; } elseif(!($ws_pwd == $ds[password])) { if($sleep) sleep(5); $error='Je hebt een ongeldig wachtwoord gebruikt.<br><br><a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; } } else $error='Jouw account is nog niet geactiveerd<br><br> <a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; } else $error='Geen gebruiker met gebruikersnaam <b>'.htmlspecialchars($ws_user).'</b> geregistreerd.<br><br> <a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; This is the login.php of the ladder/cup website function set($login){ global $config; $login[pass] = md5(md5($login[pass])); if(!mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='$login[name]' AND password='$login[pass]'"))){ $mes="1"; login($mes); exit; } $getid=mysql_query("SELECT id,act FROM members WHERE name='$login[name]'"); $getid=mysql_fetch_array($getid); if($getid[act] == 0){ error("Your account is not activated yet, you must click the link provided in your welcome email."); } //Set Cookies setcookie("tid",$getid[id], time()+60 * $login[clength]); setcookie("user",$login[name], time()+60 * $login[clength]); setcookie("pass",$login[pass], time()+60 * $login[clength]); note: Both websites are connecting with the same database, but read info from different tables. Any help would be great, the things I tried before didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/ Share on other sites More sharing options...
cooldude832 Posted February 24, 2009 Share Posted February 24, 2009 I don't see the issue here? Its 1 database you can share the tables between them without issues Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/#findComment-770241 Share on other sites More sharing options...
JonnoTheDev Posted February 24, 2009 Share Posted February 24, 2009 Why are the using 2 tables? If you want members to login to 2 sites then the should both query the same members table. Your other option albeit an unorthodox one is that if a user registers on one site their details are saved into both member tables Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/#findComment-770247 Share on other sites More sharing options...
boemboem Posted February 24, 2009 Author Share Posted February 24, 2009 both scripts are frm two different cms systems I use. I personally haven't done anything about it all because I dont know php. Could somebody help me with this? The problem for me atm is that in 1 system, it chooses everything from one table SELECT * FROM ".PREFIX."user WHERE username='$ws_user'" and the other not SELECT id FROM members WHERE name='$login[name]' AND password='$login[pass]'" and SELECT * FROM ".PREFIX."user WHERE username='$ws_user'" Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/#findComment-770256 Share on other sites More sharing options...
boemboem Posted February 24, 2009 Author Share Posted February 24, 2009 I'm getting mad this is what I get now: http://test.coldcharlie.nl/login.php Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/g35003/coldcharlie.nl/subdomains/test/login.php on line 135 this is the whole php file <? /*======================================================================*\ || #################################################################### || || # Elite Gaming Ladder v2 || # ---------------------------------------------------------------- # || || # Copyright ©2007-2008 Elite Gaming Ladder LLC. All Rights Reserved. || || # This file may not be redistributed in whole or significant part. # || || # ------------------- EGL IS NOT FREE SOFTWARE ------------------- # || || # http://www.eliteladders.com # || || #################################################################### || \*======================================================================*/ session_start(); include("./includes/incglobal.php"); if ($login[id] && !is_numeric($login[id])) { error("You have specified an Invalid Login ID!"); } switch($act){ case "setlogin": set($login); break; case "refresh": refresh(); break; case "logout": lout(); break; default: login($mes); break; } function login($mes){ global $config; if (isset($_COOKIE["user"])){ $out[body].="<br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Login</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> <b>You are already logged in!</center></td></tr> </table> </center><br /><br /><br /><br />"; }else{ $out[body].=" <br /> <center> <table width='400' border='0' cellspacing='1' bgcolor='#000000' cellpadding='1'> <form method='post'> <tr bgcolor='$config[altcolor]'> <td background='$config[bg]' width='100%' valign='center' align='left' colspan='2'> <strong>Login</strong>"; if(isset($mes)){ $out[body].="<font color='red'>(Incorrect Login)</red>"; } $out[body].=" </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='$login[name]' size='32' maxlength='15'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Password</td> <td width='60%' valign='center' align='center'><input type='password' class='input' name='login[pass]' value='' size='32' maxlength='20'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Login Length</td> <td width='60%' valign='center' align='center'> <select class='button' name='login[clength]'> <option value='60'>1 Hour</option> <option value='1440'>1 Day</option> <option value='10080'>1 Week</option> <option value='43200'>1 Month</option> <option value='83200' selected='selected'>Forever</option> </select></td> </tr> <tr bgcolor='$config[altcolorb]'> <td><a href='./register.php'>Register Now!</a></td> <td width='100%' valign='top' align='right'> <input type='hidden' name='act' value='setlogin'> <input type='submit' class='button' name='submit' value='Login >>'></td> </form> </tr> </table> <br /><br /> <table width='400' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000'> <form method='post' action='./forgotpw.php'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Forgot Password?</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='' size='25' maxlength='10'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'><img src='./includes/captcha.php' /></td> <td width='60%' valign='center' align='center'>Enter the text you see in the image.<br /> <input class='input' type='text' name='login[capt]' value='' size='40' maxlength='13'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='top' align='right' colspan='2'> <input type='submit' class='button' name='submit' value='Resend >>'></td> </form> </tr> </table> </center><br /><br />"; } include("$config[html]"); } function set($login){ global $config; $login[pass] = md5(md5($login[pass])); if(!mysql_num_rows(mysql_query("SELECT * FROM ".PREFIX."user WHERE username='$login[name]' AND password='$login[pass]'"))){ $mes="1"; login($mes); exit; } $getid=mysql_query("SELECT id,act FROM members WHERE name='$login[name]'"); $getid=mysql_fetch_array($getid); if($getid[act] == 0){ error("Your account is not activated yet, you must click the link provided in your welcome email."); } //Set Cookies setcookie("tid",$getid[id], time()+60 * $login[clength]); setcookie("user",$login[name], time()+60 * $login[clength]); setcookie("pass",$login[pass], time()+60 * $login[clength]); $out[body].="<META HTTP-EQUIV='refresh' content='0;URL=$config[scripturl]/index.php?action=myhome'> <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Login</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> Logging in..... </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } function lout(){ global $config; setcookie('tid','', time()-60 * 999999); setcookie('user','', time()-60 * 999999); setcookie('pass','', time()-60 * 999999); $out[body].="<META HTTP-EQUIV='refresh' content='0;URL=$config[scripturl]/login.php?act=refresh&type=logout'> <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Logout.</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> Logging out........ </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } function refresh(){ global $config; $out[body].=" <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Logout.</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> You have been sucessfully logged out. We hope you visit again! </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } ?> Any suggestions? :/ Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/#findComment-770363 Share on other sites More sharing options...
boemboem Posted February 25, 2009 Author Share Posted February 25, 2009 can somebody please explain me what do do or what I have to do for somebody to help me? Quote Link to comment https://forums.phpfreaks.com/topic/146708-2-websites-1-database/#findComment-770846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.