THIS IS UNFINISHED ARTICLE... I WILL UPDATE IT WHEN I HAVE TIME(like tomorrow)
This is the main idea of a login system(and some code) for noobies to understand
first... you got to make 2 new php files...
login.php
check.php
login.php have a form, which have a place to put username and password and POST to check.php..
check.php wrote:You must first make a database for phpfree chat...
session making
- Code: Select all
<?php
session_start();
$_SESSION['username'] = $_POST['username']
$_SESSION['password'] = $_POST['password']
?>
SQL connect
if you understand PHP you know you have to change some of this part to suit your need
- Code: Select all
<?php
$sql = mysql_connect("localhost", "mysqluser", "mysqlpass") or die(mysql_error());
mysql_select_db("phpfreechat") or die(mysql_error());
?>
SQL Query
- Code: Select all
<?php
$query = "SELECT pass " .
"FROM user " .
"WHERE name='$_SESSION['username']"
mysql_select_db("phpfreechat") or die(mysql_error());
$result = mysql_query($query) or die (mysql_error());
$read = mysql_fetch_array($result);
extract ($read);
if $pass=$_SESSION['password']
{
"echo <a href=chat.php>click here to continual</a>";
}
else
{echo "Wrong password";
}
?>
Let the chat.php must recive $_SESSION['username'], or it will just not work(I will post it up later)
ok.. that's the 1st php code I have ever used involved Mysql