By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

Integrating existed php systems with your site ..

PhpLover1984
P: 19
Hello everybody,
I am testing locally a php website which contains login control, so I'de like to integrate this login control with phpbb forums and at the end I want to have just one table for users and not two and if someone log in successfully into my system than he has not to log in again for the forums.

Can you pleas give me some tips to solve this problem and eventually advice or comment on my programming style and used technics in my php website? :)

I use this script to register new users:
Register:

[PHP] <?php
// make a connection and open it
$con = mysql_connect("localhost", "root", "");
if (!$con) {
die('Could not connect: ' . mysql_error());
}

// select a database
mysql_select_db("MyDB", $con);
// declare some variables ....
$userName = $_POST['username'];
$passwordHash = md5($_POST['password']);

// excute an insert query
$sql = "INSERT INTO tblUsers (username,passwoord) VALUES ('$userName,'$passwordHash')";
mysql_query($sql);

// close the db connection
mysql_close($con);
?>
[/PHP]

Log in:

[PHP] // Make connection and select a DB
$username= $_POST['username'];
$passwordHash = md5($_POST['password']);

$result = mysql_query("SELECT username FROM tblUsers WHERE username = '$username' AND passwoord = '$passwordHash' " , $con);
$raw= mysql_fetch_array($result);

if (mysql_affected_rows() < 1)
{
/* Access denied */
echo ('Sorry, your username or password was incorrect!');
}
else
{
echo('Welcome back %s!', $_POST['username']);
}

// Close connection
[/PHP]


ps; I am not a programmer, but programming is just a hobby and I don't make this site for any commercial benefits.

Thank you in advance
Jan 24 '08 #1
Share this Question
Share on Google+
2 Replies


100+
P: 115
I'm not going to say that i am an expert by any means of the imagination but it might be an idea to look in to sessions in php if you don't know much about them. This may be the solution to your problem. I am pretty new to this myself ! If this isn't i am sure someone will tell you it's a great site to get help on.
Truez
Jan 25 '08 #2

PhpLover1984
P: 19
the session you need it to control if the user is logged in or you can use it to save some informations on the site ..


but my question is about using one table for users for all already open source developed systems like forums (phpbb), blogs (wordpress), chat, quiz, contact form, games, ...

you get it?

thanks anyway

have a nice day
Jan 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.