thnx i have gone back to .asp its much better for logins than php
Login Script!!!!!
I doubt it, it is just that your current knowledge of PHP and skill at implementing what you want in PHP hasnt reached a high enough level yet.
ok ill keep on going with this just reply to me on my other post plz
I remember having a similar problem i searched around and found the code i used and it works. i hope it helps.
//login.html
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="login.php">
Username: <input type="text" name="username" size="20">
Password: <input type="password" name="password" size="20">
<input type="submit" value="Login" name="login">
</form>
</body>
</html>
//login.php code
<?
if (!isset($POST['username']) || !isset($POST['password']))
{
header("Location: login.htm");
}
elseif (empty($POST['username']) || empty($POST['password']))
{
header("Location: login.htm");
}
else
{
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$DBhost = "localhost";
$DBuser = "username";
$DBpass = "password";
$DBName = "dbname";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "SELECT * FROM users WHERE username='$user' AND password='$pass'";
$result = mysql_query($sqlquery);
//mysql_close();
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0)
{
while($row = mysql_fetch_array($result))
{
session_start();
session_register('username');
//echo 'You have successfully logged in';
header("Location: checkLogin.php");
}
}
else
{
echo 'Login Failed';
}
}
?>
//checklogin.php check that your logged in
<?
session_start();
if(session_is_registered('username'))
{
echo'Welcome you are still logged in';
}
else
{
header("Location: http://localhost/login.htm");
}
?>
//logout.php logout code
<?
session_start();
if(session_is_registered('username'))
{
session_unset();
session_destroy();
echo'You are now logged out of the system';
}
else
{
header("Location: http://localhost/login.htm");
}
?>
if you have any probs give me a shout and ill see if i can help but it works for me.
very interesting im just wondering how do you register users? and would it direct users to index.php or .html
just have a simple form with
username and password fields which post data to a adduser.php or somethign like that which uses a insert statemet such as
INSERT INTO users (username, password) VALUES ('$user', '$password');
does that answer your question?
not sure exactly what you mean by direct users to indes.html or php if you mean to add user to db then to .php but if you mean once u have logged in it can be either it does not matter
Hey,
I was in the same place you were... i needed a login script for a database that i aloready had put up to MySQL via PHPMyadmin... the login script above seems just like mine... i just authenticate the password against a pre-existing member number and their lastname against their lastname...
it took me about 4 weeks of searhcing these boards and forums and so on...
if you just can't figure it out lemme know... i'll help you with the code if i can...
Jon
ive dun my scipt now with a registration page jsut returning a few error when i try to register
Forbidden
You don't have permission to access /< on this server.
Apache/1.3.26 Server at localhost Port 80
ive dun my scipt now with a registration page jsut returning a few error when i try to register
Forbidden
You don't have permission to access /< on this server.
Apache/1.3.26 Server at localhost Port 80
Does it say what line of code is incorrect? post your code so we can check it out...
what cide do u want teh registration form cause tht is wen the error comes
Give me the reg form if that is where the error comes in... i'm having trouble though reading your posts becuas of spelling though so i think i understand...
sorry just me typing fast i know about my spelling
illl just get it now
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>New User Registration</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h3>New User Registration Form</h3>
<p><font color="orangered" size="+1"><tt><b></b></tt></font>
indicates a required field</p>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td align="right">
<p>User ID</p>
</td>
<td>
<input name="newid" type="text" maxlength="100" size="25" />
<font color="orangered" size="+1"><tt><b></b></tt></font>
</td>
</tr>
<tr>
<td align="right">
<p>Full Name</p>
</td>
<td>
<input name="newname" type="text" maxlength="100" size="25" />
<font color="orangered" size="+1"><tt><b></b></tt></font>
</td>
</tr>
<tr>
<td align="right">
<p>E-Mail Address</p>
</td>
<td>
<input name="newemail" type="text" maxlength="100" size="25" />
<font color="orangered" size="+1"><tt><b></b></tt></font>
</td>
</tr>
<tr valign="top">
<td align="right">
<p>Other Notes</p>
</td>
<td>
<textarea wrap="soft" name="newnotes" rows="5" cols="30"></textarea>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<hr noshade="noshade" />
<input type="reset" value="Reset Form" />
<input type="submit" name="submitok" value=" OK " />
</td>
</tr>
</table>
</form>
</body>
</html>
You dont have any insert statement of anykind are you trying to post data to another page where it is processes?
like trend said... there is no PHP commands associated with your code
so what do i need to put in
oh an attahced here is all of my login and registration so it might help a bit.
looks like you need to try calling your signup.php page from your Form Post part...
<form method="post" action="signup.php">
Give that a shot... this is really the first time i'm helping someone troubleshoot their code, so bear with me...