i have a form with 2 fields
username:
password:
and a submit button.
the user will enter his username and password for a remote website(not my website or my domain. eg. Gmail.com).
i want once he click the submit button.a jQuery script check these login info on gmail.com and return back the result.they are wrong or working logins. and notify the user if it is wrong logins but if it is good working login info the form will submit.
i don’t know much jQuery but i am good with php. my search find that in order to do that i need to make cross-domain scripting by using php proxy between my jQuery script and the remote domain.
i found also the simple php proxy. which looks great.but i dont know how to make the jQuery thing that connects all this together.
update: i have found this code but it is not working.
$('#submitbutton').attr('disabled', true);
$.post('/proxy.php?mode=json&nofollow=1&save_cookies=1&full_status=1&url=https://secure.dooom.com/login/login/',
{
username:$('#Name').val(),
password:$('#Password').val(),
password_strength:"strong"
}, function(data) {
if(data.status.http_code == "301"){
$.get('/proxy.php',
{
mode: 'json',
cookie_file: data.cookie_file,
full_status: 1,
remove_cookies: 1,
//url: 'http://www.dooom.com/store/index/'
url: 'http://www.dooom.com/store/index/?action=add_to_cart&products_id=3263691&is_subscription=1&freq=1&term=getstarted&content=disc99&medium=sales'
}, function(data) {
if(data.contents.search("please sign into") != -1) {
$('#submitbutton').attr('disabled', false);
alert("You must first sign in with this name on dooom before we are able to process this order. Please do so and try again.");
} else if(data.contents.search("first month only") != -1) {
form.submit();
} else {
$('#submitbutton').attr('disabled', false);
alert("You are not eligible for the product. If this is a mistake, click reset form and try again.");
}
}, "json");
} else {
$('#submitbutton').attr('disabled', false);
if(data.contents.search('Too many attempts') != -1) {
alert("You have tried too many attempts, go to dooom.com, logout and log back in doing the captcha");
} else {
alert("Incorrect dooom Username or password");
}
return false;
}
}, "json");
You need to use jquery ajax function to make an ajax request to your PHP file.
Then your PHP file can ‘authenticate’ to Gmail and return a result to that ajax function.
You can read a How to article here:
Using Gmail authentication within your web application
http://azimyasin.wordpress.com/2007/10/24/using-gmail-authentication-within-your-web-application/
And this is a PHP library you can use to authenticate to Gmail:
libgmailer for PHP
http://sourceforge.net/projects/gmail-lite/