Jump to content

Sending Radio button value using curl?


siddscool19

Recommended Posts

<form action method=post>
<input type=radio name="auswahl" id="a1">
<input type=radio name="auswahl" id="a2">
<input type=radio name="auswahl" id="a3">
</form>

 

Now i want curl to send information such that it takes action if we had selected

<input type=radio name="auswahl" id="a1">

normally

Is it possible?

Link to comment
https://forums.phpfreaks.com/topic/125173-sending-radio-button-value-using-curl/
Share on other sites

Yes, cURL can submit forms via a script. You have to tell the script what the field names are and what their values are. Here is an example

 

<?php
$username = 'user1'; // set a var for username
$password = 'thePassword'; // set a var for password

$PostFields = 'username='.$username.'&password='.$password.'&loginBtn=Submit'; // we set up the field and value pairs for the form


$ch = curl_init(); //initialize an instance of curl
curl_setopt($ch, CURLOPT_URL, 'http://mysite.com/login.php'); // set url
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1); // set the header type to post
curl_setopt($ch, CURLOPT_POSTFIELDS, $PostFields); // pass fields
$data = curl_exec($ch); // execute the request
curl_close($ch);  // close request

# echo $data; // this will echo the response from the request.
?>

 

The uncommented lines I am not real sure what they do. I am just starting with cURL as well. But it does work. I submitted a contact form on one of my sites from this script on another site.

 

 

*whoo hooo  my 1000th post*

 

Nate

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.