Location: PHPKode > projects > Babylon 5: Upheaval > b5-upheaval/login.php
<!--    

	Copyright 2007 Martin Remisch

	This file is part of "Babylon 5: Upheaval".

    "Babylon 5: Upheaval" is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as published 
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Babylon 5: Upheaval" is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with "Babylon 5: Upheaval".  If not, see <http://www.gnu.org/licenses/>.

 -->

<?php

	session_start();

?>

<html>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="format.css">

<ul id="Navigation">
Navigation
	<a href="register.php">Anmelden</a>
	<a href="login.php">Login</a>
</ul>


<form method="post" action="<?php echo $PHP_SELF;?>">
  <font face="Courier">
    Name: <input type="text" name="name"><br/>
    Pwd : <input type="password" name="pass"><br/><br/>
  <input type="submit" />
  </font>
</form>


<?php

	error_reporting(E_ALL);
	include('db_include.inc');	

	mysql_connect(HOST,USER,PASS)or die(mysql_error());
	mysql_select_db(DATABASE) or die(mysql_error());

	if (isset($_POST["name"]) && isset($_POST["pass"]))
	{
		$name     = $_POST["name"];
		$passwort = $_POST["pass"]; 

		$sql   = "SELECT id FROM users WHERE name='$name' AND pass='$passwort'";
		$query = mysql_query($sql);

		$rows = mysql_num_rows($query).mysql_error();

		if ($rows == 1)
		{
			echo "Login erfolgreich. Willkommen $name!";
			$_SESSION['name']  = $name;
			$_SESSION['zeit']  = time();
			echo "<meta http-equiv=\"refresh\" content=\"3; URL=php_functions/display_own_planets.php\">";
		}
		else 
		{
			echo "Login fehlgeschlagen.";
		}
		
	}	
	  
?>

</html>
Return current item: Babylon 5: Upheaval