Php fout

Gestart doorJoeryy12 reacties36 weergaven

13 berichten · pagina 1 van 1

Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een irritante fout: Hij blijft hele tijd zeggen stem van 1 tot 10! Maar ik stem gewoon 5 ofzo?

[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]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]]) &&[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$zFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kid[/COLOR][COLOR= #007700]])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] Je kan maar 1x stemmen per dag![/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]1[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]2[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]3[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]4[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]5[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]6[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]7[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]8[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]9[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #DD0000]10[/COLOR][COLOR= #007700])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je kan alleen stemmen van 1 tot 10[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$zFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kid[/COLOR][COLOR= #007700]];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Gestemd,[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET votes=votes+"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" WHERE naam="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] bedankt voor je stem![/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]<form method="post">

<select name="stem">

<option value="1" autocomplete="off">1</option>
<option value="2"READONLY">2</option>
<option value="3"READONLY">3</option>
<option value="4"READONLY">4</option>
<option value="5"READONLY">5</option>
<option value="6"READONLY">6</option>
<option value="7"READONLY">7</option>
<option value="8"READONLY">8</option>
<option value="9"READONLY">9</option>
<option value="10"READONLY">10</option>
</select>

<input type="submit" name="submit" value="Stem!">

</form>[/COLOR][COLOR= #007700];

}[/COLOR]

?>


Bedankt.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Volgens mij moet je post stem blijven herhalen wink

Dus

$_POST[stem] != 1 || $_POST[stem] != 2 || $_POST[stem] != 3 || etc..

toevoeging op 4 januari 2012, 11:59:26:
en btw:
if(isset($_SESSION[pid]) && $_SESSION[pid] == $zFetch[kid])
{
echo Je kan maar 1x stemmen per dag!;
}

Als je je browser sluit en dan weer opent kan je opnieuw stemmen, het geldt zo dus niet per dag maar wel browser sessie, en alle sessies verlopen als je je browser afsluit.

Ook bij websites die inloggen met alleen sessies, als je dan browser sluit en je opent hem weer ben je uitgelogd..
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik zal het even proberen

toevoeging op 4 januari 2012, 12:07:14:

[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]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]]) &&[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$zFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kid[/COLOR][COLOR= #007700]])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] Je kan maar 1x stemmen per dag![/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]1[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]2[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]3[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]4[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]5[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]6[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]7[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]8[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]9[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]10[/COLOR][COLOR= #007700])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je kan alleen stemmen van 1 tot 10[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$zFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kid[/COLOR][COLOR= #007700]];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Gestemd,[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET votes=votes+"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stem[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" WHERE naam="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] bedankt voor je stem![/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]<form method="post">

<select name="stem">

<option value="1" autocomplete="off">1</option>
<option value="2"READONLY">2</option>
<option value="3"READONLY">3</option>
<option value="4"READONLY">4</option>
<option value="5"READONLY">5</option>
<option value="6"READONLY">6</option>
<option value="7"READONLY">7</option>
<option value="8"READONLY">8</option>
<option value="9"READONLY">9</option>
<option value="10"READONLY">10</option>
</select>

<input type="submit" name="submit" value="Stem!">

</form>[/COLOR][COLOR= #007700];

}[/COLOR]

?>


Heb nu dat, maar dit werkt ook niet confused
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je kan ook =< 10 en > 0 gebruiken.
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke? Ik snap je niet echt.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
elseif($_POST[stem] >= 1 || $_POST[stem] <= 10)
{
    echo Je kan alleen stemmen van 1 tot 10;
}
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, Ik zal het proberen!
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
als dat niet werkt kan je ook nog elseif(!empty($_POST[stem]) { gebruiken.
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen een antwoord werkt emo
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan doe je iets anders fout. Alle 3 vergelijkingen gegevens kloppen.
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee Rogier, wat jij zei klopt niet. Het moet van 1 t/m 10 kunnen, bij jou geeft hij die fout bij eentje hoger dan 1 of eentje lager dan 10, bij alles dus.

Dit moet het worden:

elseif(!ctype_digit($_POST[stem]) || $_POST[stem] < 1 || $_POST[stem] > 10){
    echo Je kan alleen stemmen van 1 tot 10;
}
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
klopt ik had de > verkeerd om gezet, moeten de andere 2 alsnog werken wink
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heel erg bedankt Sjoerd! thumbsup
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