0

I'm trying to make a registration system where users that visit us and register to our website will have an account on a secondary website in order for them to be able to see some opportunities.

So here it goes: The website were I want to POST the Form and Register

My code so far

    <?php
    // set post fields
    $post = [
    // this i don't master fell free to approach the subject for future reffrance
    'authenticity_token'=>'vhmPffEAIiIbjo36K8CI77+YDQfMPBWEG8ymplsGJ0w=',
    'user[email]'=>'[email protected]',
    'user[first_name]'=>'test',
    'user[last_name]'=>'test',
    'user[password]'=>'12345678',//smart password (had to be 8char long)
    'user[country]'=>'Country(placeholder)',
    'user[mc]'=>'1560', //id of the country
    'user[lc_input]'=>'1475', //id of the dropdown
    'user[lc]'=>'1475',//id of the dropdown
    'commit'=>'REGISTER',//value of submit

    ];

    $ch = curl_init('https://auth.aiesec.org/users/sign_in');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

    // execute!
    $response = curl_exec($ch);

    // close the connection, release resources used
    curl_close($ch);

    // do anything you want with your response
    var_dump($response);
    ?>

Story:

As a user I want to be able to complete a form on domain A and at the same time have an account on domain B using CURL or even JS and AJAX.

If you have any solution to achieve this please let me know :) You can also have a look on the website.

Thank you!

Late edit

Postman POST account

I`ve made this in POSTMAN. So I think I should be able to make the for post that information. If you have other suggestions.

In this case server returns 500 as success and 200 as error (security)

Final Working Code

    <?php

    // set post fields
    $post = [
    // this i don`t master fell free to approach the subject for future reffrance
    'authenticity_token'=>'NKWAg8mGA9gUueBaJ5Og+oEOC5O2rZarZzMK+GnjuCA=',
    'user[email]'=>'',
    'user[first_name]'=>'',
    'user[last_name]'=>'',
    'user[password]'=>'',//smart password (had to be 8char long)
    'user[country]'=>'',
    'user[mc]'=>'', //id of the country
    'user[lc_input]'=>'', //id of the dropdown
    'user[lc]'=>'',//id of the dropdown
    'commit'=>'REGISTER',//value of submit

    ];

    $ch = curl_init('https://auth.aiesec.org/users/');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);


    // execute!
    $response = curl_exec($ch);

    // close the connection, release resources used
    curl_close($ch);

    // do anything you want with your response
    var_dump($response);


    ?>
2
  • What is your actual question? Commented Aug 15, 2016 at 6:16
  • I just need to be able to created an account on another website when the user completes a form on mine Commented Aug 15, 2016 at 9:34

1 Answer 1

2

You are connection via https. So you should add these lines:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

I tested your code and the website responded "Wrong username / password". That means curl is connecting correctly.

Sign up to request clarification or add additional context in comments.

7 Comments

Yup. You are right. A problem that I have identified is the way I`m going to get to the registration form cuz if you check the provided link opportunities.aiesec.org/programmes . This means that i have to click on the Login / Signup button
By the way, I think the forms POSTS to auth.aiesec.org/users for registration, not auth.aiesec.org/users/sign_in
So I should change the link to this /users. But the message on that link is this --The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.--
Will cURL look for a form and complete it or will it make a POST method like this auth.aiesec.org/users?username=2323&[email protected] ??
You should analyze the process very carefully. For example, use the Network-Tab in Firebug (if you are using Firefox) to see what is hapenning when you click the register button.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.