Page 1 of 1

Error on line 14.. Why?

Posted: Tue Sep 05, 2006 10:49 pm
by Abomination

Code: Select all

<?php
$fname=$_POST['firstname'];
$lname=$_POST['lastname'];
$uname=$_POST['username'];
$pass=$_POST['password'];
if(($fname=="Donovan")&&($lname=="Burton")&&($uname=="Abomination")&&($pass=="001001001")) {
	session_start();
	$_SESSION['auth'] = 1;
	header("location:./success.php");
}
else {
echo "Bad Login Info. Please contact the administrator.";
session_destroy();
?>
Why am I getting error on line 14

Posted: Tue Sep 05, 2006 11:00 pm
by wtf
Your

Code: Select all

else {
is missing closing

Code: Select all

}

Posted: Tue Sep 05, 2006 11:34 pm
by Abomination
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Ok so I want to make it so they can't visit the images part of the site without the session.. So anyways.. Here it is..

Auth.php =

Code: Select all

<?php

session_start();

$fname=$_POST['firstname'];
$lname=$_POST['lastname'];
$uname=$_POST['username'];
$pass=$_POST['password'];

if(($fname=="Donovan")&&($lname=="Burton")&&($uname=="Abomination")&&($pass=="001001001")) {

$_SESSION['auth'] = 1;

header("location:success.php");
} else {

echo "Bad Login Info. Please contact the adiminstrator.";
session_destroy();
}
?>
Success.php =

Code: Select all

<?php

if($_SESSION['auth'] == 1) {

	echo "Successful Login. Continue on to the images. =) <a href=\"images.php\">Images</a>";

}

else {
session_destroy();
header("Location:loginform.php");
}

?>
Images.php =

Code: Select all

<?php

if($_SESSION['auth'] == 0) {
header("Location: ./index.php");
session_destroy();
}
?>

<html>
<head>
<title>
Images
</title>
</head>
<body>

<img src="asd.jpg">
<img src="inside.jpg">
<img src="outside.jpg">
<img src="wow.jpg">
<img src="wow2.jpg">
<img src="wow3.jpg">
<img src="wow4.jpg">
<img src="wow5.jpg">
<img src="wow6.jpg">
<img src="wow7.jpg">
<img src="wow8.jpg">
<img src="wow9.jpg">
<img src="wow10.jpg">
<img src="wow11.jpg">
<img src="wow12.jpg">
<img src="wow13.jpg">
<img src="wow14.jpg">
<img src="wow15.jpg">
<img src="wow16.jpg">
<img src="wow17.jpg">
<img src="wow18.jpg">
<img src="wow19.jpg">
<img src="wow20.jpg">
<img src="wow21.jpg">
<img src="wowe1.jpg">
<img src="wowe2.jpg">
<img src="wowe3.jpg">
<img src="wowe4.jpg">
<img src="wowe5.jpg">
<img src="wowe6.jpg">
<img src="wowe7.jpg">
<img src="wowe8.jpg">
<img src="wowe9.jpg">
<img src="wowe10.jpg">
<img src="wowe11.jpg">
<img src="wowe12.jpg">
</body>
</html>
Loginform.php =

Code: Select all

<html>
<head>
<title>
Login
</head>
</title>
<body bgcolor="#000000" text="red">

<table border="0">
<tr>
<td bgcolor="black">

<form action="auth.php" method="post">

First Name: <br> <input type="text" name="firstname" style="background-color: #000000; color: red; width: 100px;" >
<br>
Last Name:<br>  <input type="text" name="lastname" style="background-color: #000000; color: red; width: 100px;">
<br>

Username:<br>  <input type="text" name="username" style="background-color: #000000; color: red; width: 100px;">
<br>
Password:<br> <input type="password" name="password" style="background-color: #000000; color: red; width: 100px;">
<br>
<br>

<input type="submit" value="Submit" style="background-color: #000000; color: red; width: 95px;">



</td>
<td width="250" cellpadding="300">
<center>
All unauthorized logins without permission of "Donovan Burton" (Abomination) Will be punished by the court of law.

Copry right.
</center>
</td>
</tr>


</form>

</table>
</body>
</html>
So please help im so confused on why it isnt working proporly.. When I try to log in it just sends me to the loginform.php.. So help me out please.. Sorry if i've said that but I need help >.<


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 06, 2006 1:36 am
by thallish
you need a session_start() in your success.php

EDIT:or in every file you want to use sessions for that matter

Posted: Wed Sep 06, 2006 2:58 am
by Ollie Saunders
Nice catch thallish.

You can avoid the else in some of those curcumstances which is always nice to do:

Code: Select all

if($_SESSION['auth'] == 1) {
   echo "Successful Login. Continue on to the images. =) <a href=\"images.php\">Images</a>";
   exit;
}
session_destroy();
header("Location:loginform.php");
Also in future please use

Code: Select all

tags rather than

Code: Select all

when posting here my eyes will like you very much