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
Abomination
Forum Newbie
Posts: 7 Joined: Tue Sep 05, 2006 8:26 pm
Post
by Abomination » Tue Sep 05, 2006 10:49 pm
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
wtf
Forum Contributor
Posts: 331 Joined: Thu Nov 03, 2005 5:27 pm
Post
by wtf » Tue Sep 05, 2006 11:00 pm
Abomination
Forum Newbie
Posts: 7 Joined: Tue Sep 05, 2006 8:26 pm
Post
by Abomination » Tue Sep 05, 2006 11:34 pm
feyd | Please use 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
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]
thallish
Forum Commoner
Posts: 60 Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark
Post
by thallish » Wed Sep 06, 2006 1:36 am
you need a session_start() in your success.php
EDIT:or in every file you want to use sessions for that matter
Last edited by
thallish on Wed Sep 06, 2006 3:07 am, edited 1 time in total.
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Wed Sep 06, 2006 2:58 am
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
when posting here my eyes will like you very much