Reputation: 731
in my project ,i am using my smf forum to control clients so i wanna create an application from which i can add member to my forum via my admin panel, in general i can do this by doing 1.login to my site ( with my admin user and pass)
2.then navigate to the url http://www.mysite.com/index.php?action=admin
3.then navigate to url http://www.mysite.com/index.php?action=regcenter
4.Fill data and click register button.
here is screen shot of adding new memeber for easy understand
http://i32.tinypic.com/wv3774.jpg
ok i started coding and i successful in doing first 3 steps ,but i am failing at 4th step
This is what i did i used live http header in firefox to grab what data it posting when registration button clicked manually i found data
user=dssa&email=asdsa%40ss.com&password=sadddsa&group=12&emailPassword=on®Submit=Register&sa=register&sc=c5efce4e867a83fa6915026342e4aa20
after that i seen page source to see what method its using in formaction its post method
> <form
> action="http://www.myaction.com/index.php?action=regcenter"
> method="post"
> accept-charset="ISO-8859-1"
> name="postForm" id="postForm">
and here is my code for doing this
begin
done first 3 step;
str:=TStringList.Create;
str.Add('user='+bsskinedit1.text);
str.Add('email='+bsskinedit1.Text+'@ss.com');
str.Add('password='+bsskinedit2.Text);
str.Add('group='+group);
str.Add('emailPassword=on');
str.Add('regSubmit=Register');
str.Add('sa=register');
str.Add('sc=c5efce4e867a83fa6915026342e4aa20');
s3:=IdHTTP1.Post('http://www.mysite.com/index.php?action=regcenter',str);
end;
but its not adding new member :(
anyhelp appreciated
thanks in advance regards
Upvotes: 2
Views: 1583
Reputation: 4565
I would assume that sc
should contain a dynamic cookie value that gets set after login. So you shouldn't hard-code it to c5efce4e867a83fa6915026342e4aa20
but instead read out the value your web-server sets it to after you login as admin and then use this value on all subsequent requests.
If sc
isn't the cookie, you could try to read the actual cookie value using TidCookieManager
Upvotes: 1
Reputation: 12943
You could use a TWebBrowser component to achieve this. Delphidabbler has some nice tutorials about manipulating the DOM, executing javascript functions, filling text fields.
Also here and here you will find more info.
Upvotes: 0