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,passw oord) VALUES ('$userName,'$p asswordHash')";
mysql_query($sq l);
// close the db connection
mysql_close($co n);
?>
[/PHP]
Log in:
[PHP] // Make connection and select a DB
$username= $_POST['username'];
$passwordHash = md5($_POST['password']);
$result = mysql_query("SE LECT username FROM tblUsers WHERE username = '$username' AND passwoord = '$passwordHash' " , $con);
$raw= mysql_fetch_arr ay($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
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,passw oord) VALUES ('$userName,'$p asswordHash')";
mysql_query($sq l);
// close the db connection
mysql_close($co n);
?>
[/PHP]
Log in:
[PHP] // Make connection and select a DB
$username= $_POST['username'];
$passwordHash = md5($_POST['password']);
$result = mysql_query("SE LECT username FROM tblUsers WHERE username = '$username' AND passwoord = '$passwordHash' " , $con);
$raw= mysql_fetch_arr ay($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
Comment