Login Page

Creating a login page form in PHP

Page 1 of 1

1 Replies - 1942 Views - Last Post: 27 December 2009 - 04:39 PM Rate Topic: -----

#1 romeyb1105   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 09-February 09

Login Page

Posted 27 December 2009 - 04:25 PM

Here's the code for the login page:



<title>Please Log In</title>

<?php include "header.php" ?>
<form method="post" action:"http://localhost/xampp/movie1.php">
  <p>Enter your username:
	<input type="text" name="user">
  <p>Enter your password:
	<input type="password" name="pass">
	<input type="submit" name="Submit"  value="Submit">

Now here's the page that I'm trying to get my login page to access after user types in their information:

//setcookie('username', 'Joe', time()+60);
$_SESSION['username'] = $_POST['user'];
$_SESSION['userpass'] = $_POST['pass'];
$_SESSION['authuser'] = 0;

//Check username and password information

	  if (($_SESSION['username']== 'Joe') AND 
			($_SESSION['userpass']== '12345'))
		  $_SESSION['authuser'] = 1;
		  echo "Sorry, but you don't have permission to view this
				page, you loser!";
<TITLE>Find my Favorite Movie!</TITLE>
<?php include "header.php" ?>
	 $myfavmovie=urlencode("Life of Brian");
	 echo "<a href='http://localhost/xampp/moviesite.php?favmovie=$myfavmovie'>";
	 echo "Click here to see information about my favorite movie!";
	 echo "</a>";

Problem: This comes from the book, Beginning PHP, Apache, MySQL Web Development and the above codes are from the exercises in the book. It states to type in username "Joe" and the password "12345" and it's supposed to take me to the movie1.php page. After I type in the user info and hit submit, the username and password disappears but it stays on the login page. I compared the code to the book and everything matches. What am I missing here? How can I get this to work?

Is This A Good Question/Topic? 0
  • +

Replies To: Login Page

#2 smacdav   User is offline

  • D.I.C Head

Reputation: 56
  • View blog
  • Posts: 177
  • Joined: 06-June 09

Re: Login Page

Posted 27 December 2009 - 04:39 PM

You have a colon instead of an equals sign:

<form method="post" action:"http://localhost/xampp/movie1.php">

should be

<form method="post" action="http://localhost/xampp/movie1.php">

This post has been edited by smacdav: 27 December 2009 - 04:39 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1