Kan je PHP in een database zetten?

Gestart doorBasDev22 reacties13 weergaven

23 berichten · pagina 1 van 2

BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Zou dit kunnen:

Voorbeeld:
Je maakt iets waardoor je paginas vanuit de website zelf kan maken...
Dit heb ik al:
HTML + JS

Zou het ook kunnen dat je PHP in de database zet en dat het er weer uit komt als PHP op de pagina??

Het script van de pagina (de belangrijkste dingen)

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./menu.php[/COLOR][COLOR= #007700]);[/COLOR]
?>
[COLOR= #0000BB]<?php
$getname[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"select * from gebruikers WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getname[/COLOR][COLOR= #007700])) {[/COLOR]

[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$name[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]];[/COLOR]
?>
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]])){[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]])){[/COLOR]
    [COLOR= #0000BB]$eigenaar[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);
    }[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]])){[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]])){[/COLOR]
        [COLOR= #0000BB]$titel[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);
        }[/COLOR]

[COLOR= #0000BB]$getpages[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"select * from paginas WHERE url = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$titel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" AND eigenaar = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$eigenaar[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$page[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getpages[/COLOR][COLOR= #007700])) {[/COLOR]

[COLOR= #0000BB]$eigenaar[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]eigenaar[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$div_een[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]div_een[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$div_twee[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]div_twee[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$div_drie[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]div_drie[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #0000BB]$ptitel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$inhoud[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<div class=error>Deze pagina is (nog) niet actief!</div>"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$inhoud[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]inhoud[/COLOR][COLOR= #007700]];
}[/COLOR]

?>
<link rel="stylesheet" href="http://leerforum.nl/newstyles.css" type="text/css"> 
<link rel="stylesheet" href="http://leerforum.nl/stylelay.css" type="text/css">
 
<script type="text/javascript" src="http://leerforum.nl/js/UBB.js"></script> 

<title>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$ptitel[/COLOR] ?></title> 
 


<p align="left">
<b><font size="1">Wil je <a href="http://www.leerforum.nl">Terug</a> naar LeerForum?</font></b><BR>

<div id="page1" class="column">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$div_een[/COLOR] ?></div>
<div id="page2" class="column">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$div_twee[/COLOR] ?></div>
<div id="page3" class="column">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$div_drie[/COLOR] ?></div>

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$eigenaar[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$naam[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<BR><BR><BR><BR>Als je deze pagina wilt bewerken klik dan <a href=http://www.leerforum.nl/pageedit?id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$page[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">Hier</a>"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{
}

}[/COLOR]
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
dus in je db staat bijvoorbeeld:

en je zet dat vanuit een DB op je site

ik denk dat datNIETwerkt
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nou dat heb ik dus geprobeerd maar er komt dan niks te staan ...
0
Berichten
747
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
zoek eens naar de functie eval
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ja dit kan. Echter moet je dan de output door eval() halen. En deze functie noemen de meeste programmeurs niet voor niets "evil".
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Waarom wil je dat überhaupt? emo
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Ja dit kan. Echter moet je dan de output door eval() halen. En deze functie noemen de meeste programmeurs niet voor niets "evil".
En hoe doe ik dat in dit script ik kan er geen soep van maken...
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Waarom wil je dat überhaupt? emo
Schoolproject yummie
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Raar schoolproject. redfaceJe moet gewoon nooit PHP code die je wilt uitvoeren in een database doen omdat je dr niks aan hebt, en omdat je enorm kwetsbaar bent voor hackers.
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alleen admins kunnen er een maken yummie
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Dan nog. Zoals ik al zei: Eval() == Evil
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dus zo:

eval() == $div_een;

??????
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Superb:
Dus zo:

eval() == $div_een;

??????

neee.... Ik bedoelde te zeggen dat de eval() functie "evil" is oftewel "kwaadaardig" oftewel "slecht" oftewel: Niet gebruiken tenzij je weet wat je doet.
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dus het advies is on het NIET te gebruiken?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ja. Het beste kan je dat inderdaad doen. Als het echt nodig is om php paginas te kunnen maken zijn fopen fwrite enz. meer functies die je kunt gebruiken.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren