User Login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

User Login

Post 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! :wink:
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

sooo, you are wanting someone to build this for you?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

It owuld help if you would post some code and ask a question about the code. Like where your having a problem...
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post 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

}



?>


?>
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

Do you have a mysql table with users setup? If so, what errors are you getting?
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post 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.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

1 reply...


http://www.hotscripts.com BIG DOT !
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post 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! :oops:
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post 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?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Could you copy the script as it is now ?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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
Post Reply