User Login
Moderator: General Moderators
- SilverMist
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 02, 2004 2:06 pm
- Location: Canada
- Contact:
User Login
I'm a complete newbie, and I have been fidgeting with this script for over a month now. What it is is a user login script I got from morrowland.com (it really isn't that good, but it's great for beginners). So if someone could help me I would be sooooo happy! Oh and I also need the script to secure every page that I don't want sneaky people to get into! 
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
- SilverMist
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 02, 2004 2:06 pm
- Location: Canada
- Contact:
Well, I actually did get a code from a friend, however it does not work.
Code: Select all
<?php
$loginname = $_POST['membername'];
$loginpassword = $_POST['password'];
// Check to see if member name already contains info
if (!isset($membername)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($membername)) {
// If non-empty, check the database for matches
// connect to MySQL
mysql_connect("localhost", "your_db_login_name", "your_password")
or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db("your_db_name")
or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT *
FROM your_db_table_name
WHERE membername='$loginname' and password='$loginpassword";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
if ($num != "0") {
echo "Member Updates";
?>
updates here
<?php
exit;
} else {
echo 'Oops!';
?>
did not login correct html here
<?php
exit;
}
}
?>
<?php
}
?>
?>- SilverMist
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 02, 2004 2:06 pm
- Location: Canada
- Contact:
- SilverMist
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 02, 2004 2:06 pm
- Location: Canada
- Contact:
WEll than i hope you did relize that you need to edit somethings... in order for that script to work ?SilverMist wrote: snippetCode: Select all
mysql_select_db("your_db_name") or die ("Unable to select database."); // Formulate the query $sql = "SELECT * FROM your_db_table_name WHERE membername='$loginname' and password='$loginpassword";
Or anyother pre-c script
- SilverMist
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 02, 2004 2:06 pm
- Location: Canada
- Contact:
Code: Select all
<form>
<input type=text name=user>
<input type=text name=pwd>
</form
make a db connection ... ect and youre done.http://www.php.net