Jump to content

Ajax login authentication


jon-e2

Recommended Posts

Im trying to work up a way to have a login form off a separate page, I don't want this to just send users to the dologin.php I want it to validate it with ajax. I don't work with xml often so I'm just hoping to get some feedback or if anyone knows of examples that are currently doing this let me know. currently here is our php file we are having a form post to.

<?php 

$femail = $_POST['femail'];
$fpassword = $_POST['fpassword'];

$api_endpoint = '../includes/api.php';
$api_user = '[i]user[/i]';
$api_password = [i]pass[/i]';

$user_email = $femail;
$user_password = $fpassword;

$data = array(
'username' => $api_user,
'password' => md5($api_password),
'action' => 'validatelogin',
'email' => urlencode($user_email),
'password2' => $user_password,
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 100);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);

echo $response;
echo $femail;
echo $fpassword;


?>



 

any input or thoughts would but very much appreciated!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated