Wenn ich in das registrierungs-feld die informationeneingebe werde ich automatisch auf die login.php datei weitergeleitet aber wenn ich dann im login die informationen eingebe werde ich nicht
registrirung.php
login.php
logout.php
secure.php
admin.php
db.txt (für die passwörter und kennwörter)
Danke im Vorraus !
registrirung.php
PHP:
<!DOCTYPE html> <!-- The new doctype -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coding A CSS3 & HTML5 One Page Template | Tutorialzine demo</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
<!-- Internet Explorer HTML5 enabling code: -->
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<style type="text/css">
.clear {
zoom: 1;
display: block;
}
</style>
<![endif]-->
</head>
<body>
<section id="page"> <!-- Defining the #page section with the section tag -->
<header> <!-- Defining the header section of the page with the appropriate tag -->
<hgroup>
<h1>copts.org</h1>
<h3>Die Welt der Kopten aus der ganzen Welt</h3>
</hgroup>
PHP:
<?php
// registrierung.php
if($_POST['submit'] == 1) {
$line = $_POST['user'] ."\t". md5($_POST['password'])."\n";
$handle = fopen('db.txt', "a");
fwrite($handle, $line)or die('Fehler beim Schreiben');
fclose($handle);
header('Location: [url]http://localhost/neu/login.php');[/url]
exit;
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<input type="hidden" name="submit" value="1" />
<table>
<tr>
<td>Benutzername:</td>
<td><input type="text" name="user" /></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Registrieren" />
</td>
</tr>
</table>
</form>
<section id="articles"> <!-- A new section with the articles -->
<!-- Article 1 start -->
<div class="line"></div> <!-- Dividing line -->
<article id="article1"> <!-- The new article tag. The id is supplied so it can be scrolled into view. -->
<h2>Photoshoot Effect</h2>
<div class="line"></div>
<div class="articleBody clear">
<figure> <!-- The figure tag marks data (usually an image) that is part of the article -->
<a href="http://tutorialzine.com/2010/02/photo-shoot-css-jquery/"><img src="http://tutorialzine.com/img/featured/641.jpg" width="620" height="340" /></a>
</figure>
<p>In this tutorial, we are creating a photo shoot effect with our just-released PhotoShoot jQuery plug-in. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus quam quis nibh fringilla sit amet consectetur lectus malesuada. Sed nec libero erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc mi nisi, rhoncus ut vestibulum ac, sollicitudin quis lorem. Duis felis dui, vulputate nec adipiscing nec, interdum vel tortor. Sed gravida, erat nec rutrum tincidunt, metus mauris imperdiet nunc, et elementum tortor nunc at eros. Donec malesuada congue molestie. Suspendisse potenti. Vestibulum cursus congue sem et feugiat. Morbi quis elit odio. </p>
</div>
</article>
<!-- Article 1 end -->
<!-- Article 2 start -->
<div class="line"></div>
<footer> <!-- Marking the footer section -->
<div class="line"></div>
<p>Copyright 2010 - YourSite.com</p> <!-- Change the copyright notice -->
<a href="#" class="up">Go UP</a>
<a href="http://tutorialzine.com/2010/02/html5-css3-website-template/" class="by">Template by Tutorialzine</a>
</footer>
</section> <!-- Closing the #page section -->
<!-- JavaScript Includes -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="jquery.scrollTo-1.4.2/jquery.scrollTo-min.js"></script>
<script src="script.js"></script>
</body>
</html>
login.php
PHP:
<?php
// login.php
require 'http://localhost/neu/secure.php';
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<input type="hidden" name="p_submit" value="1" />
<table>
<tr>
<td>Benutzername:</td>
<td><input type="text" name="p_user" value="<?php echo htmlspecialchars($_POST['p_user']); ?>" /></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="p_password" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Login" />
</td>
</tr>
</table>
</form>
logout.php
PHP:
<?php
// logout.php
session_start();
session_destroy();
?>
secure.php
PHP:
<?php
// secure.php
session_start();
if($_POST['p_submit'] == 1) {
$_SESSION['s_user'] = $_POST['p_user'];
$_SESSION['s_password'] = md5($_POST['p_password']);
}
$login = false;
$file = file('db.txt');
if($_SESSION['s_user'] != '' && $_SESSION['s_password'] != '')
foreach($file as $row) {
$row = explode("\t", $row);
$user = trim($row[0]);
$password = trim($row[1]);
if($user == $_SESSION['s_user'] && $password == $_SESSION['s_password']) {
$login = true;
}
}
if($login == false) {
if($_POST['p_submit'] == 1)
echo 'Fehler beim Login. Benutzername und/oder Passwort nicht korrekt.';
else
echo 'Bitte anmelden';
require('http://localhost/neu/login.php');
die();
}
?>
admin.php
PHP:
<?php
// admin.php
require('secure.php'); ?>
db.txt (für die passwörter und kennwörter)
PHP:
test e10adc3949ba59abbe56e057f20f883e
Danke im Vorraus !

Zuletzt bearbeitet: