Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    30
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question How to make a php robot that can log in?

    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!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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-a...press-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.


    .
    Last edited by mlseim; 02-22-2012 at 08:31 PM.

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    To log in to external sites (sites you don't run) you can do this with the cURL library for 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.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #4
    New Coder
    Join Date
    Jun 2008
    Posts
    30
    Thanks
    7
    Thanked 0 Times in 0 Posts
    @mlseim, it's an external site but I do have the username and the password for the Admin panel...

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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.

  • #6
    New Coder
    Join Date
    Jun 2008
    Posts
    30
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I'm trying with cURL, I managed to log in but I don't know how to add a user....

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Quote Originally Posted by QueenZ View Post
    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
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •