...

View Full Version : How to make a php robot that can log in?



QueenZ
02-22-2012, 09:13 PM
Hello,
I need to make a PHP script that logs into my Wordpress blog Admin panel /wp-admin/ (given the username and password) and then goes to .../wp-admin/user-new.php and automatically creates/adds a new user with the given details.

How is this done? Could you give me an example? Thanks!

mlseim
02-22-2012, 09:24 PM
I assume this in on your own website, not someone else's?

It doesn't have to be a robot that emulates an admin user ...
It needs to be a PHP script that you create to INSERT or UPDATE MySQL tables.

You just need to connect to the MySQL database and INSERT into the wp_user table
and the wp_usermeta table.

See this:
http://www.dnawebagency.com/how-to-add-an-admin-user-to-the-wordpress-database

You'll need to know things about the user, like username and password.
Will the user create their own password ... how will you know what to put there?

If you just make-up a random password, you'll have to somehow convey that back to the person logging-in.

There could be some real security issues here with a PHP script that adds a user.
Why would you want to have something like this? It's very dangerous.


NOTE: This is also the method to create an admin person in case you only had
one admin and the password was forgotten or lost. You can also do this manually
using your webhost's MySQL control panel (mysql editor). My opinion ... creating
a PHP script to add users is a stupid idea.


.

Rowsdower!
02-22-2012, 09:25 PM
To log in to external sites (sites you don't run) you can do this with the cURL library for PHP (http://php.net/manual/en/book.curl.php).

If this applies to you, do some google searches for cURL login scripts and try some things out on your site. If you get stuck in your attempts then post back here with specific questions and the code you are using at the time.

QueenZ
02-22-2012, 09:40 PM
@mlseim, it's an external site but I do have the username and the password for the Admin panel...

mlseim
02-22-2012, 09:58 PM
I've Googled it and saw a few places where remote logins were successful,
but there were some SESSION/COOKIE issues. I didn't have time to look further.

I would have to think it could be done somehow, but I've never tried it. Good luck.

QueenZ
02-22-2012, 10:30 PM
I'm trying with cURL, I managed to log in but I don't know how to add a user....

tangoforce
02-22-2012, 10:51 PM
I'm trying with cURL, I managed to log in but I don't know how to add a user....

So you need to examine the appropriate add user form and see where it submits to then :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum