chriskoller
Mitglied
Code:
<?php
session_start();
if(!isset($_SESSION['username']))
{
echo "Bitte erst <a href=\"warenkorb_start.html\">einloggen</a>!";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!empty($_SESSION['warenkorb'])) {
echo "Sie haben folgende Waren ausgew�hlt:<br /><br />";
$werte=$_SESSION['warenkorb'];
$anzahl=count($werte);
for($i=0;$i<$anzahl;$i++)
{
echo $_SESSION['warenkorb'][$i]."<br />";
}
echo "<br /><br /><a href=\"warenkorb2.php\">Einkauf fortetzen</a><br /><br /><a href=\"xxx.php\">Zur Kassa gehen</a>";
}
else {
echo "Der Warenkorb ist leer!";
}
?>
</body>
</html>
wer macht für mich was ich habe eine Vorgabe die ich mache soll, allerdings keine Ahnung wie ich es machen soll weil ich nicht weis wie das funktioniert.
Ich poste meine Vorgegebenen Dokument samt Bilder zu dem was ich machen soll, wäre nett wenn das wer für mich machen würde.
Hier mal meine Dateien :
warenkorb_start.html :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="loginform" method="post" action="warenkorb1.php">
<table border="0">
<tr>
<td>Username:</td>
<td><input type="text" name="username" size="30" maxlength="30" /></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="password" size="30" maxlength="30" />
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Login" /></td>
</tr>
</table>
</form>
</body>
</html>
warenkorb1.php :
Code:
?php
// Session starten
session_start();
// Zugangsdaten
include_once('pwd1.inc.php');
// Wurde das Formular abgesendet?
if(isset($_POST['submit'])){
$username= $_POST['username'];
$password= $_POST['password'];
}
else{
echo "Bitte erst <a href=\"warenkorb_start.html\">einloggen</a>!";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
//falsche Eingabe
if ($user != $username || $pass!= $password)
{
echo "Sie haben nicht die erforderliche Berechtigung! <br /><a href=\"warenkorb_start.html\">Zur�ck</a>";
}
//Eingabe ok
if ($user == $username && $pass== $password)
{
$_SESSION["username"] = $username;
echo "Hallo ".$_SESSION["username"]."!";
if (empty($_SESSION['warenkorb'])){
echo "<br /><br />Ihr Warenkorb ist noch leer!";
}
echo "<br /><br /><a href=\"warenkorb2.php\">Einkauf starten</a>";
}
?>
</body>
</html>
warenkorb2.php :
Code:
<?php
session_start();
if(!isset($_SESSION['username']))
{
echo "Bitte erst <a href=\"session_start.html\">einloggen</a>!";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
echo <<<END
<form name="produktwahl" action="warenkorb3.php" method="post">
Lehrheft 1 <br />
Preis: 25 Euro <br />
<input type="checkbox" name="einkauf[]" value="Lehrheft 1"><br /><br />
Lehrheft 2 <br />
Preis: 30 Euro <br />
<input type="checkbox" name="einkauf[]" value="Lehrheft 2"><br /><br />
Lehrheft 3 <br />
Preis: 55 Euro <br />
<input type="checkbox" name="einkauf[]" value="Lehrheft 3"><br /><br />
<input type="submit" name="kaufen" value="In den Warenkorb" /></td>
</form>
END;
?>
</body>
</html>
warenkorb3.php :
Code:
<?php
session_start();
if(!isset($_SESSION['username']))
{
echo "Bitte erst <a href=\"warenkorb_start.html\">einloggen</a>!";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!isset($_POST['einkauf'])) {
echo "Kein Produkt ausgew�hlt!<br /><br /><a href=\"warenkorb2.php\">Zur�ck</a>";
}
else{
// In den Warenkorb legen:
$werte=$_POST['einkauf'];
$anzahl=count($werte);
if (isset($_SESSION['warenkorb'])){
$keys_vorhanden=count($_SESSION['warenkorb']);
}
else {
$keys_vorhanden=0;
}
for($i=0;$i<$anzahl;$i++)
{
$eintrag=array_shift($werte);
$_SESSION['warenkorb'][$keys_vorhanden]= $eintrag;
$keys_vorhanden++;
}
echo "Auswahl im Warenkorb gespeichert!<br /><br /><a href=\"warenkorb2.php\">Einkauf fortetzen</a><br /><br /><a href=\"warenkorb4.php\">Warenkorb und Kassa</a>";
}
?>
</body>
</html>
warenkorb3.php :
Code:
<?php
session_start();
if(!isset($_SESSION['username']))
{
echo "Bitte erst <a href=\"warenkorb_start.html\">einloggen</a>!";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Session Test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!empty($_SESSION['warenkorb'])) {
echo "Sie haben folgende Waren ausgew�hlt:<br /><br />";
$werte=$_SESSION['warenkorb'];
$anzahl=count($werte);
for($i=0;$i<$anzahl;$i++)
{
echo $_SESSION['warenkorb'][$i]."<br />";
}
echo "<br /><br /><a href=\"warenkorb2.php\">Einkauf fortetzen</a><br /><br /><a href=\"xxx.php\">Zur Kassa gehen</a>";
}
else {
echo "Der Warenkorb ist leer!";
}
?>
</body>
</html>
Hier sind die Aufgaben :
![](http://s7.directupload.net/images/user/140219/temp/pwdw67tn.jpg)
![](http://s14.directupload.net/images/user/140219/temp/qfibc764.jpg)