|
-
Sep 17th, 2006, 11:24 AM
#1
Thread Starter
WiggleWiggle
[RESOLVED] Login Script not working...
HTML Code:
<? session_start() ?>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<?
$links = "<a href='main.php'>Click here to proceed to the main page</a>
if($user && $pass) {
if($logged_in_user == $user) {
echo "."$user"." you are already logged in. <br><br>";
echo $links;
exit;
}
$db = mysql_connect("localhost");
mysql_select_db("userlists", $db);
$result = mysql_query("SELECT * FROM users WHERE name = '".$users."'
AND password = PASSWORD('".$pass."')");
if(!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details";
exit;
}
if(mysql_num_rows($result) > 0) {
$logged_in_user = $user;
session_register("logged_in_user");
echo "Welcome, ".$logged_in_user.". <br><br>";
echo $links;
exit;
} else {
echo "Invalid login. Please try again. <br><br>";
}
} else if($user || $pass) {
echo "Please fill in both fields. <br><br";
}
?>
<form method=post action="login.php">
Your Username:
<input name="user" type=text maxlength=20 size=20>
<br>
Your Password:
<input name="pass" type=Password maxlength=10 size=10>
<br>
<input type=submit value="Login">
</form>
</body>
My usual boring signature: Something
-
Sep 17th, 2006, 01:55 PM
#2
<?="Moderator"?>
Re: Login Script not working...
What exactly is your problem. Any errors, btw to need to close the double quote here
PHP Code:
$links = "<a href='main.php'>Click here to proceed to the main page</a>";
-
Sep 17th, 2006, 07:20 PM
#3
Thread Starter
WiggleWiggle
Re: Login Script not working...
My usual boring signature: Something
-
Sep 17th, 2006, 08:55 PM
#4
Re: Login Script not working...
When you run your script it tells you what and where the error is....
PHP Code:
Parse error: syntax error, unexpected '}' in /usr/home/homtek/public_html/dclamp/login.php on line 17
-
Sep 17th, 2006, 08:59 PM
#5
Re: Login Script not working...
Here you go 
By modifing the code in bold everything now shows as it should.
PHP Code:
<? session_start() ?>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<?
$links = "<a href='main.php'>Click here to proceed to the main page</a>";
if($user && $pass) {
if($logged_in_user == $user) {
[B]echo $user." you are already logged in. <br><br>";[/B] echo $links;
exit;
}
$db = mysql_connect("localhost");
mysql_select_db("userlists", $db);
$result = mysql_query("SELECT * FROM users WHERE name = '".$users."'
AND password = PASSWORD('".$pass."')");
if(!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details";
exit;
}
if(mysql_num_rows($result) > 0) {
$logged_in_user = $user;
session_register("logged_in_user");
echo "Welcome, ".$logged_in_user.". <br><br>";
echo $links;
exit;
} else {
echo "Invalid login. Please try again. <br><br>";
}
} else if($user || $pass) {
echo "Please fill in both fields. <br><br";
}
?>
<form method=post action="login.php">
Your Username:
<input name="user" type=text maxlength=20 size=20>
<br>
Your Password:
<input name="pass" type=Password maxlength=10 size=10>
<br>
<input type=submit value="Login">
</form>
</body>
-
Sep 17th, 2006, 10:14 PM
#6
Thread Starter
WiggleWiggle
Re: Login Script not working...
nothing is bolded
My usual boring signature: Something
-
Sep 17th, 2006, 10:24 PM
#7
Addicted Member
Re: Login Script not working...
 Originally Posted by dclamp
HTML Code:
<? session_start() ?>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<?
$links = "<a href='main.php'>Click here to proceed to the main page</a>
if($user && $pass) {
if($logged_in_user == $user) {
echo "."$user"." you are already logged in. <br><br>";
echo $links;
exit;
}
$db = mysql_connect("localhost");
mysql_select_db("userlists", $db);
$result = mysql_query("SELECT * FROM users WHERE name = '".$users."'
AND password = PASSWORD('".$pass."')");
if(!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details";
exit;
}
if(mysql_num_rows($result) > 0) {
$logged_in_user = $user;
session_register("logged_in_user");
echo "Welcome, ".$logged_in_user.". <br><br>";
echo $links;
exit;
} else {
echo "Invalid login. Please try again. <br><br>";
}
} else if($user || $pass) {
echo "Please fill in both fields. <br><br";
}
?>
<form method=post action="login.php">
Your Username:
<input name="user" type=text maxlength=20 size=20>
<br>
Your Password:
<input name="pass" type=Password maxlength=10 size=10>
<br>
<input type=submit value="Login">
</form>
</body>
What is this?
Where is mister semi-colon?
=====>
Also, try adding a like to make PHP report every possible error in the script by adding:
PHP Code:
<?php
error_reporting(2047);
?>
somewhere in the script. Then copy-paste all the errors.
PS: But first make sure that you fix that major one!
-
Sep 17th, 2006, 11:03 PM
#8
Re: Login Script not working...
Short tags are evil, mm'kay.
Always use <?php ... ?>, not its inbred cousins <? ?>, <?= ?>, or <% %>; and woe betide you if you use <script language="php">.
Edit:
 Originally Posted by Seraphino
Where is mister semi-colon?
Semi-colons are implicit when the PHP block contains only a single statement.
Last edited by penagate; Sep 17th, 2006 at 11:11 PM.
-
Sep 17th, 2006, 11:07 PM
#9
Thread Starter
WiggleWiggle
Re: Login Script not working...
Here is what i have now:
PHP Code:
<? session_start(); ?>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<?php
error_reporting(2047);
?>
<?
$links = "<a href='main.php'>Click here to proceed to the main page</a>
if($user && $pass) {
if($logged_in_user == $user) {
echo "."$user"." you are already logged in. <br><br>";
echo $links;
exit;
$db = mysql_connect("localhost");
mysql_select_db("userlists", $db);
$result = mysql_query("SELECT * FROM users WHERE name = '".$users."'
AND password = PASSWORD('".$pass."')");
if(!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details";
exit;
}
if(mysql_num_rows($result) > 0) {
$logged_in_user = $user;
session_register("logged_in_user");
echo "Welcome, ".$logged_in_user.". <br><br>";
echo $links;
exit;
} else {
echo "Invalid login. Please try again. <br><br>";
}
} else if ($user || $pass) {
echo "Please fill in both fields. <br><br";
}
?>
<form method=post action="login.php">
Your Username:
<input name="user" type=text maxlength=20 size=20>
<br>
Your Password:
<input name="pass" type=Password maxlength=10 size=10>
<br>
<input type=submit value="Login">
</form>
</body>
</html>
My usual boring signature: Something
-
Sep 17th, 2006, 11:10 PM
#10
Re: Login Script not working...
-
Sep 18th, 2006, 12:17 AM
#11
Re: Login Script not working...
For some reason the [B] tags don't work in php code??
I changed the below row and the login page came up for me.
PHP Code:
echo $user." you are already logged in. <br><br>";
-
Sep 18th, 2006, 06:05 AM
#12
Re: Login Script not working...
 Originally Posted by dclamp
The script tells you where the error is. Look on the lineadn the lines above and below any you will no doubt find it.
-
Sep 18th, 2006, 05:24 PM
#13
Thread Starter
WiggleWiggle
Re: Login Script not working...
 Originally Posted by visualAd
The script tells you where the error is. Look on the lineadn the lines above and below any you will no doubt find it.
yeah but i am a total newbie to PHP. that is really, the only code i know so it doesnt help me when it tells me what is wrong, and i dont know why it is wrong. if that helps you guys understand . i will try to fix it all. I belive the turtourial was kind of old. i got it off of http://www.vtc.com. really good site.
thanks all who helped
My usual boring signature: Something
-
Sep 18th, 2006, 05:41 PM
#14
Thread Starter
WiggleWiggle
Re: Login Script not working...
ok, now i am getting a diffrent error:
Code:
Parse error: syntax error, unexpected T_STRING in /usr/home/homtek/public_html/dclamp/login.php on line 14
My usual boring signature: Something
-
Sep 19th, 2006, 03:04 AM
#15
Re: Login Script not working...
The code in post #5 works fine. (remember to remove ["B"] and ["/B"] tags )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|