Page 1 of 1
User Login
Posted: Tue Mar 02, 2004 2:06 pm
by SilverMist
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!

Posted: Tue Mar 02, 2004 2:07 pm
by infolock
sooo, you are wanting someone to build this for you?
Posted: Tue Mar 02, 2004 2:09 pm
by Illusionist
It owuld help if you would post some code and ask a question about the code. Like where your having a problem...
Posted: Tue Mar 02, 2004 2:12 pm
by SilverMist
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
}
?>
?>
Posted: Tue Mar 02, 2004 2:20 pm
by andre_c
Do you have a mysql table with users setup? If so, what errors are you getting?
Posted: Tue Mar 02, 2004 2:25 pm
by SilverMist
I am getting an error on line 12, the headers. And I took them out and still recieved errors. I have removed the script from my site, but I can reupload if you need to know anymore errors.
Posted: Tue Mar 02, 2004 2:30 pm
by ol4pr0
Posted: Tue Mar 02, 2004 2:31 pm
by SilverMist
I love hotscripts. However, all the scripts I downloaded from there (and believe me, I have got quite a few), none seem to work for me. I'm beginning to think I'm a total idiot!

Posted: Tue Mar 02, 2004 2:34 pm
by ol4pr0
SilverMist wrote: snippet
Code: 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";
WEll than i hope you did relize that you need to edit somethings... in order for that script to work ?
Or anyother pre-c script
Posted: Tue Mar 02, 2004 2:44 pm
by SilverMist
I have edited and edited and edited. I could probably write that script in my sleep. But since a solution to fixing that seems, well, impossible, does anyone know a good script I could get?
Posted: Tue Mar 02, 2004 3:03 pm
by ol4pr0
Could you copy the script as it is now ?
Posted: Tue Mar 02, 2004 3:05 pm
by ol4pr0
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