GET -> POST

Gestart doorDylan17 reacties35 weergaven

18 berichten · pagina 1 van 2

Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik wil van een GET een POST maken alleen loop ik vast:

[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]username[/COLOR][COLOR= #007700]])) {[/COLOR]
[COLOR= #0000BB]$user_echo[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
?>
tekst ;)
<form method="post" action="index.php?a=betalen">
<input type="hidden" name="user" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$user_echo[/COLOR] ?>">
<input type="submit" name="done" value="Doorgaan  ->">
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]done[/COLOR][COLOR= #007700]])) {[/COLOR]
        
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]BETALEN[/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]username[/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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]done[/COLOR][COLOR= #007700]])) {[/COLOR]
     
     

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]];
        
    }

}[/COLOR]    
?>


ERROR": Notice: Undefined index: user in C:xampphtdocsindex.php on line 24
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik snap niet wat je wilt.. ?
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Als het scherm word geopend staat er ?username=gebruikersnaam in de URL. Dan moet de gebruiker op Doorgaan klikken en wil ik dan de username een $_POST word. Dan moet de gebruiker betalen, en staat er in de URL ?a=betalen. Zodra de gebruik heeft betaalt moet die doorgestuurd naar index.php (dus zonder get) zonder de $_GET. Dan wil ik gebruik maken van $_POST en dan krijg ik dus die error.
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom moet dat een $_POST worden?
Waarom maak je er dan niet gewoon een string van?

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

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Omdat mollie ?toegangscode= stuurd en dan krijg ik dus z`n *** URL

/index.php?username=jan?toegangscode=34567643

en volgens mij kan dat niet
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik snap eigenlijk niet echt wat je bedoeld?
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Sanderc schreef:
Ik snap eigenlijk niet echt wat je bedoeld?
Sorry, ik ben misschien nu niet zo duidelijk maar ik zou het nog eens uitleggen:

1) Klant opent betaalscherm, in URL staat: index.php?username=Jan
2) Klant drukt op Doorgaan, in de URL staat:index.php?a=betalen
3) Klant betaald. (Word dus via mollie doorgestuurd naar: index.php?toegangscode=12345

Dat laatste werkt dus niet.
En met nummer 3 bedoel ik dus van $_GET naar $_POST
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Opslaan als sessie wink
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]][/COLOR]
?>


??
Kan het nu even niet uitproberen
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bovenaan je code altijd session_start(); zetten wink
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]][/COLOR]
?>
??
Kan het nu even niet uitproberen

Omgekeerd wink
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Maartenl schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]][/COLOR]
?>
??
Kan het nu even niet uitproberen
Omgekeerd wink
[COLOR= #0000BB]<?php
$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
?>


Maar wat als $_GET[username] niet in de URL staat?
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom redirect je het niet i.p.v. een session van te maken.
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Maartenl schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]][/COLOR]
?>
??
Kan het nu even niet uitproberen
Omgekeerd wink
[COLOR= #0000BB]<?php
$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
?>


Maar wat als $_GET[username] niet in de URL staat?

Dan check je dat toch?

[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]username[/COLOR][COLOR= #007700]]))
{[/COLOR]
    [COLOR= #FF8000]//iets[/COLOR]
[COLOR= #007700]}[/COLOR]
?>


Als je dat bedoeld...
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Maartenl schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]][/COLOR]
?>
??
Kan het nu even niet uitproberen
Omgekeerd wink
[COLOR= #0000BB]<?php
$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
?>


Maar wat als $_GET[username] niet in de URL staat?
aah Wat wil je dan opslaan ? emo
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