I'm trying to make automatic register script with curl.
I have html form:
<form method="post" action="/register/submit" autocomplete="off" id="js-register-form">
<input type="hidden" name="__csrf_token" value="28030357" />
<input name="nick" type="text" size="15" maxlength="15" value="" class="form-control" />
<input name="pass" type="password" size="15" maxlength="15" class="form-control" />
<input name="sex" type="radio" value="V" /> vyras </label>
<input name="sex" type="radio" value="M" /> moteris </label>
<select name="age_day" class="form-control">
<option>Diena</option>
<option>1</option><option>2</option><option>3</option>                    
</select>
<select name="age_month" class="form-control">
<option>Mėnuo</option>
<option value="1">Sausis</option><option value="12">Gruodis</option></select>
<select name="age_year" class="form-control">
<option>Metai</option>
<option>2001</option><option>2000</option><option>1999</option>                   </select>
<input name="email" type="text" value="" size="15" maxlength="50" class="form-control" />
<select name="city_id" class="form-control"><option value="">Miestas</option><option value="1340915">Akmenė</option><option value="1341068">Alytus</option><option value="1341242">Anykščiai</option><option value="1341276">
</select>
<button type="submit" title="Registruotis" class="btn btn-signup js-register-form-submit">Registruotis</button>
</form>
and this is my curl script, but it doesn't work. What s wrong with it?:
<?php 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://login.com....html");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "__csrf_token=28030357&nick=pixelis98722&pass=qwerty&sex=V&age_day=12&age_month=04&age_year=2000&[email protected]&city_id=1343628"); 
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
// further processing ....
if ($server_output == "OK") { echo"gerai"; } else { echo "bad"; }
?>
but doesn't work. Whats wrong with it?


__csrf_tokenwill ultimately change and is held in session serverside, so whatever value you use will not be valid for multiple requests. your need to scrape it everytime and use session persistence in the curl request.