Beste,
Weet iemand hoe ik met PHP op een button kan klikken in een form, op mijn eigen server. In de zelfde pagina.
Weet iemand hoe ik met PHP op een button kan klikken in een form, op mijn eigen server. In de zelfde pagina.
<input type="submit" name="BUTTONNAME"> Allard schreef:Ow, maar waarom zou je willen dat je automatisch op een button klikt.Je begrijpt het niet hé? Ik wil dat hij automatisch op dat button klikt...
<META HTTP-EQUIV="Refresh" content="3;http://www.jouwebsitenaam.nl/"> Allard schreef:Weet iemand hoe ik met PHP op een button kan klikken in een form, op mijn eigen server. In de zelfde pagina.Beste,
Semmiiee schreef:Niet zo agressief reageren als mensen iets niet begrijpen, omdat je het niet duidelijk uitlegt<input type="submit" name="BUTTONNAME">

Allard schreef:http://www.jonasjohn.de/snippets/php/post-request.htmNou, met JavaScript kan het wel. Maar kan het ook in PHP. Want er is ook nog wel een andere oplossing. Hoe kan ik met PHP naar een pagina gaan (doorsturen), maar ook gegevens meegeven met een post request? Ik heb deze gevonden, maar ik snap niet hoe ik hem moet gebruiken:

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"hierdeurlwatgepostmoetworden"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$ch[/COLOR] [COLOR= #007700]=[/COLOR] curl_init[COLOR= #007700]();[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_URL[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POST[COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POSTFIELDS[COLOR= #007700],[/COLOR] [COLOR= #DD0000]submit=submit[/COLOR][COLOR= #007700]);[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_RETURNTRANSFER[COLOR= #007700],[/COLOR] TRUE[COLOR= #007700]);[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_USERAGENT[COLOR= #007700],[/COLOR] [COLOR= #DD0000]Mozilla/4.0[/COLOR][COLOR= #007700]);[/COLOR]
curl_exec[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR]
?> Daiman schreef:Niet alle hosts ondersteunen cURL. Houd daar rekening mee! En je script werkt ook helemaal voor geen ene reet.met curl kan je posten.
voorbeeld:[COLOR= #0000BB]<?php $url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"hierdeurlwatgepostmoetworden"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$ch[/COLOR] [COLOR= #007700]=[/COLOR] curl_init[COLOR= #007700]();[/COLOR] curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_URL[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR] curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POST[COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR] curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POSTFIELDS[COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]);[/COLOR] curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_RETURNTRANSFER[COLOR= #007700],[/COLOR] TRUE[COLOR= #007700]);[/COLOR] curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_USERAGENT[COLOR= #007700],[/COLOR] [COLOR= #DD0000]Mozilla/4.0[/COLOR][COLOR= #007700]);[/COLOR] curl_exec[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR] ?>
[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= #FF8000]//gesubmit[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt geklikt!"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form action="" method="POST">
<input type="submit" name="submit" value="Verzenden" />
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
En je kan het ook normaal zeggen en niet gelijk zo bot "het werkt voor geen ene reet"