bestand-aanpassen-met-php
Gesponsorde koppelingen
PHP script bestanden
edit_config.php
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
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
73
74
75
76
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
73
74
75
76
<?php
$config = 'config.php' ;
// als de config bestaat de $vars inlezen
if(file_exists($config))
{
include($config);
}
// anders initialiseren
else
{
$siteurl = '';
$sitetitel = '';
$description = '';
$keywords = '';
$email = '';
}
// is er gepost dan de $vars overnemen
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$siteurl = addslashes($_POST['siteurl']);
$sitetitel = addslashes($_POST['sitetitel']);
$description = addslashes($_POST['description']);
$keywords = addslashes($_POST['keywords']);
$email = addslashes($_POST['email']);
// Deze data wordt zo dadelijk
// in config.php geschreven
// Je kan natuurlijk altijd
// meer tekst er in schrijven!
$configinhoud = '<?php
$siteurl = "' . $siteurl . '";
$sitetitel = "' . $sitetitel . '";
$description = "' . $description . '";
$keywords = "' . $keywords . '";
$email = "' . $email . '";
?>';
$openconfig = fopen("" .$config."", "w");
fwrite($openconfig, $configinhoud);
// De data is er nu ingeschreven
// Dus nu gaan we het bestand weer netjes sluiten!
fclose($openconfig);
}
?>
<form method="post" action="edit_config.php">
<fieldset class="config">
<table border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td width="120"><label>Site url</label></td>
<td><input type="text" class="balk" name="siteurl" value="<?php echo $siteurl;?>" /></td>
</tr>
<tr>
<td width="120"><label>Site titel</label></td>
<td><input type="text" class="balk" name="sitetitel" value="<?php echo $sitetitel;?>" /></td>
</tr>
<tr>
<td width="120"><label>Description</label></td>
<td><input type="text" class="balk" name="description" value="<?php echo $description;?>" /></td>
</tr>
<tr>
<td width="120"><label>Keywords</label></td>
<td><input type="text" class="balk" name="keywords" value="<?php echo $keywords;?>" /></td>
</tr>
<tr>
<td width="120"><label>E-mail</label></td>
<td><input type="text" class="balk" name="email" value="<?php echo $email;?>" /></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" class="button" name="proceed" id="proceed" value="Verstuur" /></td>
</tr>
</table>
</fieldset>
</form>
$config = 'config.php' ;
// als de config bestaat de $vars inlezen
if(file_exists($config))
{
include($config);
}
// anders initialiseren
else
{
$siteurl = '';
$sitetitel = '';
$description = '';
$keywords = '';
$email = '';
}
// is er gepost dan de $vars overnemen
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$siteurl = addslashes($_POST['siteurl']);
$sitetitel = addslashes($_POST['sitetitel']);
$description = addslashes($_POST['description']);
$keywords = addslashes($_POST['keywords']);
$email = addslashes($_POST['email']);
// Deze data wordt zo dadelijk
// in config.php geschreven
// Je kan natuurlijk altijd
// meer tekst er in schrijven!
$configinhoud = '<?php
$siteurl = "' . $siteurl . '";
$sitetitel = "' . $sitetitel . '";
$description = "' . $description . '";
$keywords = "' . $keywords . '";
$email = "' . $email . '";
?>';
$openconfig = fopen("" .$config."", "w");
fwrite($openconfig, $configinhoud);
// De data is er nu ingeschreven
// Dus nu gaan we het bestand weer netjes sluiten!
fclose($openconfig);
}
?>
<form method="post" action="edit_config.php">
<fieldset class="config">
<table border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td width="120"><label>Site url</label></td>
<td><input type="text" class="balk" name="siteurl" value="<?php echo $siteurl;?>" /></td>
</tr>
<tr>
<td width="120"><label>Site titel</label></td>
<td><input type="text" class="balk" name="sitetitel" value="<?php echo $sitetitel;?>" /></td>
</tr>
<tr>
<td width="120"><label>Description</label></td>
<td><input type="text" class="balk" name="description" value="<?php echo $description;?>" /></td>
</tr>
<tr>
<td width="120"><label>Keywords</label></td>
<td><input type="text" class="balk" name="keywords" value="<?php echo $keywords;?>" /></td>
</tr>
<tr>
<td width="120"><label>E-mail</label></td>
<td><input type="text" class="balk" name="email" value="<?php echo $email;?>" /></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" class="button" name="proceed" id="proceed" value="Verstuur" /></td>
</tr>
</table>
</fieldset>
</form>
config.php:
deze gewoon aanmaken de inhoud word er automatisch in gezet.