|
|
 |
Author |
Message |
QWERTYtech

Joined: 03 May 2006
Posts: 47
|
Posted:
Wed Jul 05, 2006 8:02 pm |
  |
I want to create a member access page and I want it to check the usrnm and password to my database... That part I can do.... Now how can i make it open a page in /_private? But i don't want anyone to just be able to browse to /_private.... I don't know if Im going about this the hard way or not but I would greatly appreciate any help....
Also, i don't want the login to store any information in a cookie for future reference.... All this scripts i have found store information in a cookie. I need someone to be able to login to this site without someone being able to go behind them and login also.....
Thanks for any help,
QWERTYtech |
|
|
   |
 |
cigraphics

Joined: 21 Aug 2005
Posts: 148
Location: Romania, Pitesti
|
Posted:
Wed Jul 12, 2006 11:52 am |
  |
you can make it with php and mysql or with .htpasswd and .htaccess ( with groups) |
|
|
    |
 |
QWERTYtech

Joined: 03 May 2006
Posts: 47
|
Posted:
Sat Jul 15, 2006 8:06 pm |
  |
what would be easeir? i have worked on some stuff but i cant get it to work right..... look at this code please.....
main_login.php
Code: |
############### Code
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
|
checklogin.php
Code: |
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from signup form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
|
login_success.php
Code: |
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>
|
logout.php
Code: |
// Put this code in first line of web page.
<?
session_start();
session_destroy();
?>
|
php5 - checklogin.php
Code: |
<?php
ob_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
|
This is the code that im running but it seems not to run right.
http://redbeardcustoms.no-ip.info/WebSite/main_login.php |
|
|
   |
 |
cigraphics

Joined: 21 Aug 2005
Posts: 148
Location: Romania, Pitesti
|
Posted:
Mon Jul 31, 2006 10:09 am |
  |
|
    |
 |
|
|
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
Powered by phpBB
© 2001, 2002 phpBB Group :: FI Theme
All times are GMT
|