0

I am trying to create a PHP bot for a project for my cs classs that will automatically log me in to a site and perform certain tasks once that is complete. I have been doing some research and I believe the best way to acomplish this would be wish cURL however I am new to PHP so I may be taking the wrong approach. Here is what I have so far:

<?php
	$curl = curl_init();
	curl_setopt ($curl, CURLOPT_URL, "http://www.mywebsite.com");
	curl_setopt ($curl, CURLOPT_POST, 1);
	curl_setopt ($curl, CURLOPT_POSTFIELDS, "usr=username&pswd=password");
	
	curl_exec($curl);
	echo curl_error($curl);
	curl_close($curl);
	
?>

When I run this script I just get a broken link error in my browser, can anyone offer any suggestions? Thanks for your help.

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by haye321
0

this is your code:

<?php
	$curl = curl_init();
	curl_setopt ($curl, CURLOPT_URL, "http://www.mywebsite.com");
	curl_setopt ($curl, CURLOPT_POST, 1);
	curl_setopt ($curl, CURLOPT_POSTFIELDS, "usr=username&pswd=password");
	
	curl_exec($curl);
	echo curl_error($curl);
	curl_close($curl);
	
?>

Try doing this:

<?php
	$curl = curl_init("http://www.mywebsite.com");
	curl_setopt ($curl, CURLOPT_POST, 1);
	curl_setopt ($curl, CURLOPT_POSTFIELDS, "usr=username&pswd=password");
	
	curl_exec($curl);
	echo curl_error($curl);
	curl_close($curl);
	
?>
0

I am still getting the broken link error, am I correct in assuming that the variables usr and pswd are supposed to be named the same as the forms that they correspond to on the pages I'm logging into?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.