edit save file in php op de server
Ik heb website waar ik aantaal banner op heb. de banners worden ingeladen via include.. de banner adres zit in een php file opgeslagen. dus elke banner 1 php file.
nu ik zou graag willen een admin panel maken om te kunnen via server de banner code aanpassen.
wie kan me helpen?
ik heb deze code .. maar ik mis de save button.
[page=save_file.php]
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?php
session_start();
$handle = fopen($_POST['original_file_name'], "w");
$text = $_POST['file_contents'];
if(fwrite($handle, $text) == FALSE){
$_SESSION['error'] = '<span class="redtxt">There was an error</span>';
}else{
$_SESSION['error'] = '<span class="redtxt">File edited successfully</span>';
}
fclose($handle);
header("Location: ".$_POST['page']);
?>
session_start();
$handle = fopen($_POST['original_file_name'], "w");
$text = $_POST['file_contents'];
if(fwrite($handle, $text) == FALSE){
$_SESSION['error'] = '<span class="redtxt">There was an error</span>';
}else{
$_SESSION['error'] = '<span class="redtxt">File edited successfully</span>';
}
fclose($handle);
header("Location: ".$_POST['page']);
?>
[page=read_file.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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<form action="savecontents.php" method="post">
<textarea name="file_contents" style="width:700px;height:600px;">
<?php
$fileName = "location/of/orignal/file/my_file.php";
$handle = fopen($fileName, "r");
while (!feof($handle)){
$text = fgets($handle);
echo $text;
}
?>
</textarea>
<input type="hidden" value="<? echo $fileName; ?>" name="original_file_name" />
</form>
<body>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<form action="savecontents.php" method="post">
<textarea name="file_contents" style="width:700px;height:600px;">
<?php
$fileName = "location/of/orignal/file/my_file.php";
$handle = fopen($fileName, "r");
while (!feof($handle)){
$text = fgets($handle);
echo $text;
}
?>
</textarea>
<input type="hidden" value="<? echo $fileName; ?>" name="original_file_name" />
</form>
<body>
</body>
</html>
graag elke help is welkom.
Gewijzigd op 03/11/2013 13:17:49 door - Ariën -
Alex alexander op 03/11/2013 11:10:48:
ik heb deze code .. maar ik mis de save button.
Daar is submit toch voor?
Kijk op bv. http://www.w3schools.com/html/html_forms.asp (en dan iets naar beneden scrollen).
ik heb al in html iets opgemaakt daar moet alleen de funtie edit en submit inkomen.
mijn verzoek is een soort admin panel maken voor mijn banner file. dat is per banner een file.
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
77
78
79
80
81
82
83
84
85
86
87
88
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
77
78
79
80
81
82
83
84
85
86
87
88
<html>
<head>
<meta http-equiv="Content-Language" content="nl">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Admin page</title>
</head>
<p align="center">
</p>
<p align="center"><u><font size="6">Banner setup admin panel</font></u></p>
<p align="center">
</p>
<body bgcolor="#C0C0C0">
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="center"><input type="text" name="T1" size="83"></p>
<p align="center"><input type="submit" value="Submit" name="B1"><input type="button" value="Edit" name="B2">
Header banner 468x60.php <font size="6">Banner header</font></p>
</form>
<table border="1" width="99%" height="333">
<tr>
<td width="625">
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T2" size="42"><input type="submit" value="Submit" name="B3"><input type="button" value="Edit" name="B4">
banner 120x60-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T3" size="42"><input type="submit" value="Submit" name="B5"><input type="button" value="Edit" name="B6">
banner 120x60-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T4" size="42"><input type="submit" value="Submit" name="B7"><input type="button" value="Edit" name="B8">
banner 120x60-3.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T5" size="42"><input type="submit" value="Submit" name="B9"><input type="button" value="Edit" name="B10">
banner 120x240.php</p>
</form>
<p><input type="text" name="T13" size="42"><input type="submit" value="Submit" name="B25"><input type="button" value="Edit" name="B26">
banner 120x60-4.php<p><input type="text" name="T14" size="42"><input type="submit" value="Submit" name="B27"><input type="button" value="Edit" name="B28">
banner 120x60-5.php<p> <p> <p> <p><font size="6">Banner left Colom</font></td>
<td>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T6" size="42"><input type="submit" value="Submit" name="B11"><input type="button" value="Edit" name="B12">
banner 160x600-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T7" size="42"><input type="submit" value="Submit" name="B13"><input type="button" value="Edit" name="B14">
banner 1600x80-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T8" size="42"><input type="submit" value="Submit" name="B15"><input type="button" value="Edit" name="B16">
banner 160x80-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T9" size="42"><input type="submit" value="Submit" name="B17"><input type="button" value="Edit" name="B18">
banner 160x600-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T10" size="42"><input type="submit" value="Submit" name="B19"><input type="button" value="Edit" name="B20">
banner 160x80-3.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T11" size="42"><input type="submit" value="Submit" name="B21"><input type="button" value="Eidt" name="B22">
banner 160x80-4.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T12" size="42"><input type="submit" value="Submit" name="B23"><input type="button" value="Edit" name="B24">
banner 160x80-5.php</p>
</form>
<p><font size="6">Banner Right Colom</font></td>
</tr>
</table>
</body>
</html>
<head>
<meta http-equiv="Content-Language" content="nl">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Admin page</title>
</head>
<p align="center">
</p>
<p align="center"><u><font size="6">Banner setup admin panel</font></u></p>
<p align="center">
</p>
<body bgcolor="#C0C0C0">
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="center"><input type="text" name="T1" size="83"></p>
<p align="center"><input type="submit" value="Submit" name="B1"><input type="button" value="Edit" name="B2">
Header banner 468x60.php <font size="6">Banner header</font></p>
</form>
<table border="1" width="99%" height="333">
<tr>
<td width="625">
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T2" size="42"><input type="submit" value="Submit" name="B3"><input type="button" value="Edit" name="B4">
banner 120x60-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T3" size="42"><input type="submit" value="Submit" name="B5"><input type="button" value="Edit" name="B6">
banner 120x60-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T4" size="42"><input type="submit" value="Submit" name="B7"><input type="button" value="Edit" name="B8">
banner 120x60-3.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T5" size="42"><input type="submit" value="Submit" name="B9"><input type="button" value="Edit" name="B10">
banner 120x240.php</p>
</form>
<p><input type="text" name="T13" size="42"><input type="submit" value="Submit" name="B25"><input type="button" value="Edit" name="B26">
banner 120x60-4.php<p><input type="text" name="T14" size="42"><input type="submit" value="Submit" name="B27"><input type="button" value="Edit" name="B28">
banner 120x60-5.php<p> <p> <p> <p><font size="6">Banner left Colom</font></td>
<td>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T6" size="42"><input type="submit" value="Submit" name="B11"><input type="button" value="Edit" name="B12">
banner 160x600-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T7" size="42"><input type="submit" value="Submit" name="B13"><input type="button" value="Edit" name="B14">
banner 1600x80-1.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T8" size="42"><input type="submit" value="Submit" name="B15"><input type="button" value="Edit" name="B16">
banner 160x80-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T9" size="42"><input type="submit" value="Submit" name="B17"><input type="button" value="Edit" name="B18">
banner 160x600-2.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T10" size="42"><input type="submit" value="Submit" name="B19"><input type="button" value="Edit" name="B20">
banner 160x80-3.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T11" size="42"><input type="submit" value="Submit" name="B21"><input type="button" value="Eidt" name="B22">
banner 160x80-4.php</p>
</form>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Users\mandoza\Desktop\lfscore\Livescores v2.00\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="left"><input type="text" name="T12" size="42"><input type="submit" value="Submit" name="B23"><input type="button" value="Edit" name="B24">
banner 160x80-5.php</p>
</form>
<p><font size="6">Banner Right Colom</font></td>
</tr>
</table>
</body>
</html>
Gewijzigd op 03/11/2013 13:16:58 door - Ariën -
- Je hebt vreemde formulier namen als T10 /T11 etc. Daar kan je niks mee beginnen, het is gewoon onduidelijk
- Ik zie zaken nar voren komen zoals --WEBBOT-SELF-- en 'U-File'. Ik durf te wedden dat dat met FrontpageExtenties te maken heeft die bijna geen enkele hosting zal ondersteunen.
- Voor elk item een nieuwe <form> tag, terwijl dat bedoeld is om één geheel formulier mee te omvatten.
Als ik zo zie is dit nog spul uit Frontpage 2000 (!). Vergeet niet dat we inmiddels in 2013 zitten, en dat HTML al behoorlijk verder ontwikkeld is en dat er een hoop op de schop is gegaan.
Is het niet zinnig om eerst eens te kijken naar een tutorial over HTML, en daarna eens op PHP te richten. Ik heb het idee dat je nu iets wilt, maar door verouderde technieken en onwetendheid maar iets in elkaar flanst.
Gewijzigd op 03/11/2013 13:23:13 door - Ariën -
dat was met frontpage aangemaakt.
in het koort opnieuw:
ik heb aantaal files.
120x60-1.php ( dat is foro voor banner format 120x60) dat wordt via include ingeladen in index pagina.
120x60-2.php
120x60-3.php
120x60--4.php
120x60-5.php
dat zijn de banner in linke colom
dan rechte colom:
160x600-1.php
160x80-1.php
160x80-2.php
160x600-2.php
160x80-3.php
160x80-4.php
160x80-5.php
en aan de top heb ik banner
468x60.php
dus de vraag is een admin pagina maken om te kunnen online die banner code aanpassen.. in plaats van dat ik ieder keer via ftp werken.
bij voorbaat dank.
En gooi Frontpage weg, daar heb je niks meer aan. Een alternatief is Dreamweaver of Kompozer, of zelf met HTML-codes de site opbouwen. (aanrader, je weet precies wat je doet)
de enige wat ik graag wil zo pagina dat ik kan achter de schremen de banner aanpassen.
ik hoop dat iemand kan me helpen met maken van de admin pagina voor banners.
ik gebruik zelf wel editplus. ik kan de code niet schrijven maar wel edit en aanpassen :-)
Alleen nog een <input type="submit" value="Aanpassen" /> eraan toevoegen binnen je <form>-onderdeel. Misschien dat je er dan nog een paar dingen eraan moet veranderen, maar de code ziet er verder goed uit.
Gewijzigd op 03/11/2013 13:56:25 door - Ariën -
ja dat werkt dank u voor de help.
Graag gedaan :)