PHP gevorderde |
|
<?php
######################
# Connectie Database #
######################
$host = "localhost";
$user_h = "user";
$pass = "pas";
$db = "databasenaam";
mysql_connect($host,$user_h,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
################
# Verwerkingen #
################
$select = "SELECT * FROM Geld WHERE id='1'";
$result = mysql_query($select) or die(mysql_error());
while($obj = mysql_fetch_object($result))
{
$geld = $obj->geld;
$id_1 = $obj->id;
}
$query = "SELECT * FROM gwn";
$sql = mysql_query($select) or die(mysql_error());
while($obje = mysql_fetch_object($sql))
{
$geld_data = $obje->geld;
$memberid_data = $obje->memberid;
}
// Scrijven Database
if($id_1 != $memberid_data)
{
$in ="INSERT INTO gwn(memberid) VALUES ('".$id_1."')";
mysql_query($in) or die(mysql_error());
echo "GELUKT";
}
// Proberen
else
{
if(isset($_POST["kopmunt"]))
{
if(rand(0,1) == 1)
{
if($_POST["check"] == "kop")
{
$bewerking = $geld_data + 4000;
echo "gelukt.";
mysql_query("UPDATE gwn SET geld='".$bewerking."' WHERE memberid='".$id_1."'");
}
else
{
echo "Je hebt verloren.";
mysql_query("DELETE FROM gwn WHERE memberid='".$id_1."'");
}
}
else
{
if($_POST["check"] == "munt")
{
$bewerking = $geld_data + 4000;
echo "gelukt.";
mysql_query("UPDATE gwn SET geld='".$bewerking."' WHERE memberid='".$id_1."'");
}
else
{
echo "Je hebt verloren.";
mysql_query("DELETE FROM gwn WHERE memberid='".$id_1."'");
}
}
}
elseif(isset($_POST["stop"]))
{
$bewerking = $geld + $geld_data;
mysql_query("UPDATE geld SET geld='".$bewerking."' WHERE id='".$id_1."'");
}
}
?>
<table>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<tr>
<th>Kop</th><td><input type="radio" name="check" value="kop" /></td>
</tr>
<tr>
<th>Munt</th><td><input type="radio" name="check" value="munt" /></td>
</tr>
<tr>
<td><input type="submit" value="Gok" name="kopmunt" /></td>
<td><input type="submit" value="Stop" name="stop" /></td>
</tr>
</form>
</table>
<?php ###################### # Connectie Database # ###################### $host = "localhost"; $user_h = "user"; $pass = "pas"; $db = "databasenaam"; ################ # Verwerkingen # ################ $select = "SELECT * FROM Geld WHERE id='1'"; { $geld = $obj->geld; $id_1 = $obj->id; } $query = "SELECT * FROM gwn"; { $geld_data = $obje->geld; $memberid_data = $obje->memberid; } // Scrijven Database if($id_1 != $memberid_data) { $in ="INSERT INTO gwn(memberid) VALUES ('".$id_1."')"; } // Proberen else { if(isset($_POST["kopmunt"])) { { if($_POST["check"] == "kop") { $bewerking = $geld_data + 4000; mysql_query("UPDATE gwn SET geld='".$bewerking."' WHERE memberid='".$id_1."'"); } else { echo "Je hebt verloren."; mysql_query("DELETE FROM gwn WHERE memberid='".$id_1."'"); } } else { if($_POST["check"] == "munt") { $bewerking = $geld_data + 4000; mysql_query("UPDATE gwn SET geld='".$bewerking."' WHERE memberid='".$id_1."'"); } else { echo "Je hebt verloren."; mysql_query("DELETE FROM gwn WHERE memberid='".$id_1."'"); } } } elseif(isset($_POST["stop"])) { $bewerking = $geld + $geld_data; mysql_query("UPDATE geld SET geld='".$bewerking."' WHERE id='".$id_1."'"); } } ?> <table> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> <tr> <th>Kop</th><td><input type="radio" name="check" value="kop" /></td> </tr> <tr> <th>Munt</th><td><input type="radio" name="check" value="munt" /></td> </tr> <tr> <td><input type="submit" value="Gok" name="kopmunt" /></td> <td><input type="submit" value="Stop" name="stop" /></td> </tr> </form> </table>
De useres blijven maar in de database komen hoe komt dit??
|