zakgeld-bijhouder

Gesponsorde koppelingen

PHP script bestanden

  1. zakgeld-bijhouder

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!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" lang="en" xml:lang="en">

    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>zakgeld</title>
    </head>
    <body>
<table border="1">
<?php
echo "<tr><td><b>naam</b></td><td><b>per week</b></td><td><b>totaal(week ".date("W").")</b></td></tr>";
$numofmen = 0;
$total = 0;
$totalperweek = 0;
mysql_connect("••••", "••••", "••••") or die(mysql_error());
mysql_select_db("••••") or die(mysql_error());

if(isset($_POST['name']) && isset($_POST['europerweek']) && isset($_POST['current']) && $_POST['name'] != "" && $_POST['europerweek'] > 0 && is_numeric($_POST['europerweek']) && is_numeric($_POST['current']) && !is_numeric($_POST['name']) && $_POST['current'] < 10000 && $_POST['europerweek'] < 1000 ) {
mysql_query("INSERT INTO zakgeld (last_update,name,per_week,current) VALUES ('".date("W")."','".mysql_real_escape_string ($_POST['name'])."','".mysql_real_escape_string ($_POST['europerweek'])."','".mysql_real_escape_string ($_POST['current'])."')") or die(mysql_error());
echo "Gefeliciteerd, je bent toegevoegd aan onze database.<br />";
}



if(isset($_POST['name']) && ($_POST['name'] == "" || is_numeric($_POST['name'])))
echo "Uw naam is ongeldig.<br />";

if( isset($_POST['current']) && isset($_POST['europerweek']) && (!is_numeric($_POST['europerweek']) || !is_numeric($_POST['current'])))
echo "Bedragen mogen alleen getallen en '.' bevatten.<br />";

if(isset($_POST['europerweek']) && isset($_POST['current']) && ($_POST['current'] >= 10000 || $_POST['europerweek'] >= 1000 || $_POST['europerweek'] <= 0 || $_POST['current'] < 0))
echo "Het door u opgegeven bedrag ligt buiten de maximale/minimale waarde.<br />";

$result = mysql_query("SELECT * FROM zakgeld")
or die(mysql_error());

while($row = mysql_fetch_array( $result )) {

mysql_query("UPDATE zakgeld SET last_update='".date("W")."', current='". ((date("W") - $row['last_update']) * ($row['current'] + $row['per_week']) + $row['current']) ."' WHERE name='".$row['name']."'")
or die(mysql_error());

echo "<tr><td>";
echo htmlspecialchars ($row['name']);
echo "</td><td>&euro;";
echo htmlspecialchars ($row['per_week']);
echo "</td><td>&euro;";
echo htmlspecialchars ($row['current']);
echo "</td></tr>";
$numofmen++;
$total+= $row['current'];
$totalperweek+= $row['per_week'];
}

echo "<tr><td><b>totaal</b></td><td>&euro;".$totalperweek."</td><td>&euro;".$total."</td></tr>";
echo "<tr><td><b>gemiddeld</b></td><td>&euro;".($totalperweek / $numofmen)."</td><td>&euro;".($total / $numofmen)."</td></tr>";
?>

</table>

<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
naam:<br /><input type="text" name="name" /><br />
zakgeld per week:<br /><input type="text" name="europerweek" /><br />
ik heb nu:<br /><input type="text" name="current" /><br />
<input type="submit" value="submit" /><br />
</form>
<p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" />
    </a>
</p>

    </body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.