Betaal script

Gestart doorMarv17 reacties30 weergaven

18 berichten · pagina 1 van 2

Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Hallo,
Ik heb een mini-shopje gemaakt. maar nu wil ik een pagina purchase.php

ik geef aan purchase de variabel B mee dat is het id van het shopproduct.

dus purchase.php?b=1

Nu wil ik graag dat als je op die pagina komt dat er dan credits van de gebruiker worden afgeschreven.

Als de badge 49 kost en hij heeft 48 credits, dan mag hij hem niet kunnen kopen.

En als er geen b= wordt meegegeven een tekst neerzetten: Ga terug naar de shop.
Wie kan dat voor me maken?

Beloning: Komen we wel uit
0
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][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]credits[/COLOR][COLOR= #007700]] <[/COLOR][COLOR= #DD0000]49[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] niet genoeg credits[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
hier het script [COLOR= #007700]}[/COLOR]
?>


ziets is de badge check
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
ik moet de hele pagina.

En het is per badge
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
als je een beetje knutselt en hulp vraagt kom je er wel uit
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
$credits = de gebruiker zijn credits
$row[cost] = De kosten van het product.

heb nu dit:

if($credits <$row[cost]){
echo  niet genoeg credits; } else {
echoGenoeg credits;


Maar dat werkt niet. Ik wil dus checken of de user zijn credits niet lager zijn dan row cost.

Wie weet hoe ik dit anders moet doen?
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom werkt die dan niet?
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
idunno, geeft steeds weer dat er wel genoeg credits zijn, terwijl dit niet zo is
0
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]klik[/COLOR][COLOR= #007700]]))
    {[/COLOR]
          [COLOR= #0000BB]$queryToevoeg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT 
                                            * 
                                        FROM
                                            leden_leden 
                                        WHERE 
                                            uId = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
          [COLOR= #0000BB]$rowToevoeg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$queryToevoeg[/COLOR][COLOR= #007700]);[/COLOR]
          [COLOR= #0000BB]$creditshDB[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$rowToevoeg[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uCredits[/COLOR][COLOR= #007700]];[/COLOR]
          [COLOR= #0000BB]$credituDB[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$creditshDB[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700];[/COLOR]
            
          [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$creditshDB[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])
          {[/COLOR]
              [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE 
                                leden_leden 
                            SET 
                                uCredits="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$credituDB[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" 
                            WHERE
                                uId="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE
                                leden_leden 
                            SET 
                                uRang = 3
                            WHERE 
                                uId = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                 [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Succesvol vip gekocht![/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 heb niet genoeg credits![/COLOR][COLOR= #007700];
          }
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        ?>


moet je zelf aanpassen naar wat je wil
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Dat heeft niks te maken met wat ik wil, dit is een appart ledensysteem.
Efferinie schreef:
$credits = de gebruiker zijn credits
$row[cost] = De kosten van het product.

heb nu dit:

if($credits <$row[cost]){
echo  niet genoeg credits; } else {
echoGenoeg credits;
Maar dat werkt niet. Ik wil dus checken of de user zijn credits niet lager zijn dan row cost.

Wie weet hoe ik dit anders moet doen?

Als deze check werkt red ik me wel weer.
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat is de column naam van het aantal credits van een gebruiker? Gewoon credits?
Zoja:

[COLOR= #0000BB]<?php[/COLOR]

     [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]credits[/COLOR][COLOR= #007700]] <[/COLOR] [COLOR= #DD0000].$row[[/COLOR]cost[COLOR= #DD0000]].[/COLOR][COLOR= #007700]){[/COLOR]
       [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Niet genoeg![/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]Blaaaaat[/COLOR][COLOR= #007700];
       }[/COLOR]
?>
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
unexpected t string in if($credits < .$row[cost].){
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oeps, foutje.

[COLOR= #0000BB]<?php[/COLOR]

     [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]credits[/COLOR][COLOR= #007700]] <[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]cost[/COLOR][COLOR= #007700]){[/COLOR]
       [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Niet genoeg![/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]Blaaaaat[/COLOR][COLOR= #007700];
       }[/COLOR]
?>
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
if($credits < $row[cost]{
       echo Niet genoeg!;
          }
            else
                   {

            Echo Blaaaaat;
       }


unexpected T_ECHO bij niet genoeg!?
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Uh, dan zal ik het niet meer weten hoor. confused
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Is al klaar smileAlleen hoe maak ik die mysql query nu?

mysql_query("UPDATE users SET `credits - $row[cost]

Wie kan me daarmee ff helpen.
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