verplichte velden in update script
Code (php)
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
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
<?php
include("config.inc.php");
if(isset($_POST[updaten])) {
$cursus=$_POST[cursustype];
$prijs=$_POST[cursusprijs];
$begindatum=$_POST[cursusbegindatum];
$einddatum=$_POST[cursuseinddatum];
$upid=$_POST[cursusnummer];
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="update cursus set cursustype='$cursus',cursusprijs='$prijs',cursusbegindatum='$begindatum',cursuseinddatum='$einddatum' where cursusnummer='$upid'" ;
$res=mysql_db_query("$dabase","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
else {
echo '<div align="center"><h3>De gegevens zijn in de database aangepast</h3><br></div>';
mysql_close($mysql_id);
exit;
}
}
$upid=$_GET[cursusnummer];
if(isset($upid)) {
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="select * from cursus where cursusnummer = '$upid'";
$res=mysql_db_query("$database","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
$row=mysql_fetch_row($res);
?>
include("config.inc.php");
if(isset($_POST[updaten])) {
$cursus=$_POST[cursustype];
$prijs=$_POST[cursusprijs];
$begindatum=$_POST[cursusbegindatum];
$einddatum=$_POST[cursuseinddatum];
$upid=$_POST[cursusnummer];
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="update cursus set cursustype='$cursus',cursusprijs='$prijs',cursusbegindatum='$begindatum',cursuseinddatum='$einddatum' where cursusnummer='$upid'" ;
$res=mysql_db_query("$dabase","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
else {
echo '<div align="center"><h3>De gegevens zijn in de database aangepast</h3><br></div>';
mysql_close($mysql_id);
exit;
}
}
$upid=$_GET[cursusnummer];
if(isset($upid)) {
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="select * from cursus where cursusnummer = '$upid'";
$res=mysql_db_query("$database","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
$row=mysql_fetch_row($res);
?>
<form action="" method="post"
<fieldset>
<label for = 'cursustype'>
cursustype:
</label>
<input type="text" name="cursustype" value="">
<label for = 'prijs'>
prijs:
</label>
<input type="text" name="cursusprijs" value="">
<label for = 'Begindatum'>
begindatum:
</label>
<input type="text" name="cursusbegindatum" value="">
<label for = 'einddatum'>
einddatum:
</label>
<input type="text" name="cursuseinddatum" value="">
<label for = 'cursusnummer'></label>
<input type="hidden" name="cursusnummer" value="">
<label for = 'verstuur'></label>
<input type="submit" name="updaten" value="Gegevens updaten">
<label for = 'wissen'></label>
<input type = 'Reset' name = 'Wissen' value = 'Wissen' />
</fieldset>
</form>
Code (php)
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
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
<?php
mysql_close($mysql_id);
}
else {
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="select * from cursus";
$res=mysql_db_query("$database","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
$aantal_lijnen=mysql_num_rows($res);
$aantal_velden=mysql_num_fields($res);
echo "<br><br>";
echo '<table border=2 celpadding=2 width="100%">';
for($i=0;$i<$aantal_velden;$i++) {
printf("<th class=\"db\">%s</th>",mysql_field_name($res,$i));
}
echo "<th class=\"db\">Update</th>"; # toegevoegd
for($i=0;$i<$aantal_lijnen;$i++) {
$row=mysql_fetch_row($res);
echo '<tr>';
foreach($row as $col) {
$upid=$row[0];
if(!$col) $col=" ";
echo "<td class=\"db\">$col</td>";
}
echo "<td class=\"db\"><a href=\"aanpassen.php?cursusnummer=$upid\" class=\"links\">Update</a></td></tr>"; # veranderd
}
echo "</table>";
echo '<br><br>';
mysql_close($mysql_id);
}
?>
mysql_close($mysql_id);
}
else {
$mysql_id=mysql_connect("$datahost","$username","$password");
$sql="select * from cursus";
$res=mysql_db_query("$database","$sql",$mysql_id);
$fout=mysql_errno($mysql_id);
if ($fout != 0) {
$fout=mysql_error($mysql_id);
echo '<font color="#FF2306">' . $fout . '</font>';
mysql_close($mysql_id);
echo '</body></html>';
exit;
}
$aantal_lijnen=mysql_num_rows($res);
$aantal_velden=mysql_num_fields($res);
echo "<br><br>";
echo '<table border=2 celpadding=2 width="100%">';
for($i=0;$i<$aantal_velden;$i++) {
printf("<th class=\"db\">%s</th>",mysql_field_name($res,$i));
}
echo "<th class=\"db\">Update</th>"; # toegevoegd
for($i=0;$i<$aantal_lijnen;$i++) {
$row=mysql_fetch_row($res);
echo '<tr>';
foreach($row as $col) {
$upid=$row[0];
if(!$col) $col=" ";
echo "<td class=\"db\">$col</td>";
}
echo "<td class=\"db\"><a href=\"aanpassen.php?cursusnummer=$upid\" class=\"links\">Update</a></td></tr>"; # veranderd
}
echo "</table>";
echo '<br><br>';
mysql_close($mysql_id);
}
?>
Dit geldt uiteraard ook voor alle overige strings in jouw code...