php beveiligen? Hoe?

Gestart doorPaull10 reacties54 weergaven

11 berichten · pagina 1 van 1

Paull

Lid · Topicstarter

Berichten
1.641
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben een beginnend php scripter. Ik heb een berichtenbalkje gemaakt zonder mysql. Kan iemand zorgen dat als er gerefreshd wordt. Het bericht niet voor de tweede keer wordt opgeslagen?

<form action="verzend.php" method="post">
<table>
<tr>
<td>Naam: </td>
<td><input type="text" name="naam" maxlength="10"></td>
</tr>
<tr>
<td>Bericht: </td>
<td><input type="text" name="bericht" maxlength="50"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Post bericht!"></td>
</form>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]] ||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt niet alles ingevuld![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$safe[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]<B> [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</B> - [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] || [/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$fp[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]data.txt[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]a+[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fwrite"]fwrite[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fp[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$safe[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fp[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je bericht is toegevoegd![/COLOR][COLOR= #007700];
}
}[/COLOR]
?>

<marquee direction="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]data.txt[/COLOR][COLOR= #007700]);[/COLOR] ?></marquee>
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
zet het tusssen

if ($_GET[id] == 1) {
hier je php
}

en dan moet je ?id=1 laten aanroepen en dan moet je meta refresh boven in zetten
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
fwrite($fp, $fp.$safe);

misschien?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
ik wil wel helpen maar geen scammers
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<body>
<form action="?id=1" method="post">
<table>
<tr>
<td>Naam: </td>
<td><input type="text" name="naam" maxlength="10"></td>
</tr>
<tr>
<td>Bericht: </td>
<td><input type="text" name="bericht" maxlength="50"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Post bericht!"></td>
</form>
[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR]id[COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]] ||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt niet alles ingevuld![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$safe[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]<B> [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</B> - [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] || [/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$fp[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]data.txt[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]a+[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fwrite"]fwrite[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fp[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$safe[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fp[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je bericht is toegevoegd![/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: verzend.php"[/COLOR][COLOR= #007700]);
}
}
}[/COLOR]
?>

<marquee direction="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]data.txt[/COLOR][COLOR= #007700]);[/COLOR] ?></marquee>


werkt dat mischien ? ik kan het namelijk niet op localhost testen omdat me xampp raar doet confused
0
Berichten
325
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik gebruik altijd een javascript truukje.... mss wat amateuristisch, maar het werkt wel.
wat het doet: het ververst een pagina indien een mysql query succesvol wordt uitgevoerd. het script ververst de pagina zonder de post-data te verzenden:

[COLOR= #0000BB]<?PHP[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]....[/COLOR][COLOR= #007700]])
{[/COLOR]
     [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]" hier je query"[/COLOR][COLOR= #007700]))
     {[/COLOR]
             ?>
             <script language="JavaScript">
             <!--
              window.location=document.location;
             //-->
             </script>
     [COLOR= #0000BB]<?PHP[/COLOR] [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
     }[/COLOR]
     [URL="http://www.php.net/else"]else[/URL]
     [COLOR= #007700]{[/COLOR] 
     [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
     }
}[/COLOR]?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
je kan ook header("location") gebruiken
0
Paull

Lid · Topicstarter

Berichten
1.641
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
header location gaat bij mij altijd buggen. Ps daiman. Ty
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
enuuh

dat met dat hij dan bugt dan kan je dit gebruiken

error_reporting (0); // dit zet de fout weergave uit
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Daiman schreef:
enuuh
dat met dat hij dan bugt dan kan je dit gebruiken

error_reporting (0); // dit zet de fout weergave uit

Dat moet je NOOIT doen. Je moet nooit erros gaan verbergen. Zorg gewoon dat je goed script. wel kan je eventueel E_NOTICE uitzetten, maar normaal gesproken dien je alle fouten gewoon te laten zien.
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet zeker al je fouten oplossen wat Rik ook zegt.
Want soms kan je ook vast zitten met je script terwijl je heel veel erros hebt.
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