miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Specific miniBB Support Forums / Specific /  
 

Website Login difficulties

 
Author mrbigdog
Partaker
#1 | Posted: 19 Oct 2009 16:36 
Hi all,

I have successfully installed my forum onto my 'localhost' system and have tried to integrate the login system to work on an external page of my site. The article on this was very good, and I have adapted the default scripts to suit my needs. However, although the form variables for username and password are being passed to the comparison script, no cookie is being set - so instead of returning to the page I logged in from and displaying a welcome message - the log in form is still there. Here is my code:

Log in page:

<?php
if(!isset($_SESSION['auth']
) or !isset($_SESSION['ID'])){
// If the user isn't logged in, show them the form...

echo 'Please enter your log in details below, or</p>
<form action="my_auth.php" method="POST" name="login">
<table id="login_website" summary="Log in to the Karting Days web site.">
<tr>
<th scope="col" abbr="login" class="nobg">login</th>

<th scope="col" abbr="login" class="nobg"><input type="text" name="login" size="27" value="" /></th>
</tr>
<tr>
<th scope="col" abbr="Password" class="nobg">Password</th>

<th scope="col" abbr="Password" class="nobg"><input type="password" name="password" size="27" value="" /></th>
</tr>
<tr>
<td></td>
<th scope="col" abbr="go" class="inputButton"><input type="submit" name="go" value="go" /></th>

</tr>
</table>
</form>';
}

else {echo 'You are logged in as '.$_SESSION['auth'].' (ID: '.$_SESSION['ID'].') <a href="my_auth.php?logout=1">Logout</a>';}


?>

Now the Code for My_auth.php:

<?php
/* Comparison script */

$page=$_SERVER['HTTP_REFERER'];

if(isset($_POST['login']) and isset($_POST['password'])){

mysql_connect('localhost:8888', 'root', 'root') or die ('<b>Database/configuration error.</b>');
mysql_select_db('karting') or die ('<b>Database/configuration error (DB is missing).</b>');

if(isset($_POST['login'])) $name=htmlspecialchars(trim($_POST['login']),ENT_QUOTES); else $name='';
if(isset($_POST['password']
)) $pass=htmlspecialchars(trim($_POST['password']),ENT_QUOTES); else $user_pwd='';

if($res=mysql_query("select ID, name, pass from my_users where name='{$name}' and pass='{$pass}'") and mysql_num_rows($res)>0 and $row=mysql_fetch_row($res)){

session_start();
$_SESSION['auth']=$row[1];
$_SESSION['ID']=$row[0];

}

}
elseif(isset($_GET['logout'])){
session_start();
unset($_SESSION['auth']);
unset($_SESSION['ID']);
}
header("Location: $page");

?>

Can anybody help? Is it because i'm using XAMPP/Mac and local server - or am i missing something obvious?

Any other topics on how to get this integrated?

Many thanks in advance!

Paul.

Author Paul
Lead Developer 
#2 | Posted: 20 Oct 2009 03:11 
You need to debug the script and make sure the data you pass is really present in the database. I guess the mysql_query condition is just not performing well, that's why the session may not be set.

Author mrbigdog
Partaker
#3 | Posted: 20 Oct 2009 10:17 
Hi Paul,

Thanks for the reply! Iv'e checked the database and everything is present and correct. Does the code look ok to you? any obvious errors?

Thanks.

Author Paul
Lead Developer 
#4 | Posted: 21 Oct 2009 04:43 
I see a lot of imperfect things in such code. Anyway, I can't say precisely what's wrong. Deep debugging is needed - may be it's something guilty on your server side.

Specific miniBB Support Forums / Specific /
 Website Login difficulties
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑