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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.