werkt niet

Gestart doorSmiegles10 reacties71 weergaven

11 berichten · pagina 1 van 1

Smiegles

Lid · Topicstarter

Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]))
    {[/COLOR]
            [COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]150[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])
            {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren1[/COLOR][COLOR= #007700];
            }[/COLOR]
         [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen![/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen!2[/COLOR][COLOR= #007700];
            }
        }[/COLOR] 
?>
<form action="" method="post" name="submit">
<input type="submit" name="vecht"> 
</form>


ik heb deze code,
Maar hij geeft gewoon geen output nidanoppes.
weet iemand wat er fout is?
0
Berichten
1.479
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
0
Smiegles

Lid · Topicstarter

Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee dat hoeft niet.
0
Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]))
    {[/COLOR]
            [COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]150[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])
            {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren1[/COLOR][COLOR= #007700];
            }[/COLOR]
         [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen![/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen!2[/COLOR][COLOR= #007700];
            }
        }[/COLOR] 
?>
<form action="" method="post">
<input type="submit" name="submit" value="vecht"> 
</form>


zo?
0
Smiegles

Lid · Topicstarter

Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Marjolein schreef:
[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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]))
    {[/COLOR]
            [COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]150[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])
            {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je hebt verloren1[/COLOR][COLOR= #007700];
            }[/COLOR]
         [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen![/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt gewonnen!2[/COLOR][COLOR= #007700];
            }
        }[/COLOR] 
?>
<form action="" method="post">
<input type="submit" name="submit" value="vecht"> 
</form>
zo?

Jha die is goed heel erg besankt
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Gebruik liever geen isset($_POST[submit]) maar ($_SERVER[REQUEST_METHOD] == POST)
Staat wat netter.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Gebruik liever geen isset($_POST[submit]) maar ($_SERVER[REQUEST_METHOD] == POST)
Staat wat netter.

($_SERVER[REQUEST_METHOD] === POST) is het beste. POST moet tussen aanhalingstekens anders ziet ie het als een variable die met define geset is. === is omdat de REQUEST_METHOD een string én de tekst POST moet zijn
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ja die aanhalingstekens was een klein snelheidsfoutje. En === is niet perse noodzakelijk.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Klopt, maar vind ik persoonlijk wel het beste smile
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat doe ik ook altijd yummie
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik gebruik === alleen voor true en false. yummie (Maar nu dwalen we eigenlijk een beetje van het onderwerp af...)
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