Created
August 27, 2009 21:42
-
-
Save laszlokorte/176582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Startguthaben definieren | |
define("startguthaben", 100); | |
define("waehrung", "$"); | |
session_start(); | |
//Variablen initialisieren | |
//------------------------ | |
if(!isset($_SESSION['konto'])){ | |
$_SESSION['konto'] = startguthaben; | |
} | |
//------------------------ | |
function status(){ | |
?>Konto: <?php echo $_SESSION['konto']." ".waehrung; ?> <br /> <?php | |
} | |
//Wenn Kontostand =0 | |
function tip(){ | |
if($_SESSION['konto'] == 0){ | |
session_destroy(); //Diesen Satz ausgeben | |
return('Du hast verloren!<br /><a href="index.php">Neues Spiel!</a>'); | |
} | |
?> | |
<form method="post" action="index.php?section=kontrolle"> | |
<input type="radio" name="wert" value="1" /> Kopf <br /> | |
<input type="radio" name="wert" value="0" /> Zahl <br /> | |
<u>Einsatz:</u> <input type="text" name="einsatz" /> | |
<input type="submit" value="Setzen" /> | |
</form> | |
<?php | |
} | |
function kontrolle(){ | |
// wenn der Einsatz > Kontostand ist wird | |
if($_POST['einsatz'] > $_SESSION['konto']){ | |
// dies hier ausgeben | |
return(' | |
Einsatz war echt zu hoch. Sei ein wenig bescheidener.<br /> | |
<a href="index.php?section=tip">Nochmal versuchen.</a>'); | |
} | |
?> | |
Dein Tip: | |
<?php | |
if($_POST['wert'] == 1){ | |
echo "Kopf"; | |
} else { | |
echo "Zahl"; | |
} | |
?> | |
<br /> | |
Dein Einsatz: <?php echo $_POST['einsatz']." ".waehrung; ?> <br /> | |
<?php | |
$random = rand(0,1); | |
// wenn die Wette richtig war | |
if($_POST['wert'] = $random){ | |
echo "Deine Wette war richtig!";// wird dieser Satz ausgegeben und der Einsatz mit dem vorherigen Kontostand addiert | |
$_SESSION['konto'] = $_SESSION['konto'] + $_POST['einsatz']; | |
} else { // wenn die Wette falsch war | |
echo "Deine Wette war falsch!"; // wird dieser Satz ausgegeben und der Einsatz mit dem vorherigen Kontostand subtrahiert | |
$_SESSION['konto'] = $_SESSION['konto'] - $_POST['einsatz']; | |
} | |
echo '<br />'; // Neuer Kontostand wird dem User angezeigt, aufgefordert zum Weiterspielen | |
echo 'dein neuer Kontostand ist: '.$_SESSION['konto']." ".waehrung; | |
echo '<br />'; | |
echo '<a href="index.php?section=tip">Nochmal!</a>'; | |
} | |
//+++++++++++++++++++++++++++++++// | |
//+++ MADE BY JONATHAN ZIELKE++++// | |
//+++++++++++++++++++++++++++++// | |
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> | |
<head> | |
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" /> | |
<meta name="keywords" language="de" content="Jonathan's Verzeichnis,HTML, PC, Technik, CSS, Computer, Programmierer, Download, Shareware, Freeware, Software, Open-source, HTML-Einstieg, HTML-Tutorial, PHP, lustige Witze, lustige Sprüche, lustig, free download, tutorial, filezilla, openoffice, statistiken, homepage, HTML hilfe, HP, browser, HTML Editor,suche HTML Editor, Bildbearbeitungsprogramm, Paint Net, Audacity, Naruto Mugen, Mugen, " /> | |
<meta name="description" language="de" content="Ein kleines süßes Archiv, mit zahlreichen Downloads, lustigen Witzen, atemberaubenden Statistiken und einem zuverlässigem Webmaster" /> | |
<meta name="author" language="de" content="Jonathan Zielke"> | |
<meta name="generator" language="de" content="PSPad"> | |
<link href="http://www.chambionic.de/joni/css/moneytime.css" rel="stylesheet" type="text/css" /> | |
<link rel="shortcut icon" type="image/x-icon" href="http://www.chambionic.de/joni/images/icon.ico"> | |
<title>Moneytime by Jonathan Zielke</title> | |
</head> | |
<body> | |
<center><img src="http://www.chambionic.de/joni/images/moneytime.png" alt="Moneytime"></center><br> | |
<div id="box"><?php | |
switch($_GET['section']){ | |
case "tip": | |
status(); | |
echo tip(); | |
break; | |
case "kontrolle": | |
status(); | |
echo kontrolle(); | |
break; | |
default: | |
status(); | |
echo tip(); | |
break; | |
} | |
?></div> | |
<div id="footer"><font color="black"><p>Made by <a target="_blank" href="http://www.chambionic.de/joni">Jonathan Zielke</a></p></font></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment