2017-04-24 122 views
0

我想代碼給我的形式對其他網站的響應,我也得到例如在代碼的同一頁面的響應從其他網站響應

有一個字段名爲 「把你的電子郵件重置您的密碼」 「」

我的想法是這樣的

$url = 'http://example.com/reset.php'; 
&email = [email protected]; 

//now i want excute email in the form inside the url 

do $email in the form of this $url and give me the response 

例如

您的電子郵件地址不存在

和肯定,我想這一切,而不去網站上面,我只是想知道是什麼形式的響應,當我把郵件

我希望你得到了我的想法 ,我很抱歉爲我的英語。

+0

你正在尋找被稱爲'cURL'工具:https://secure.php.net/manual/en/book。 curl.php – David

+0

我如何使用它?我試圖理解它,但不可能 – AllordEmad

+0

「我不明白」不是一個真正的可回答的問題。你有什麼嘗試?從簡單的例子開始(快速谷歌搜索會發現很多),然後從那裏開始。 – David

回答

0

jQuery('#submit').click(function() { 
 
    var email = jQuery('#email').val(); 
 

 
    jQuery.post('http://example.com/reset.php', {email: email}).done(function (result) { 
 
     jQuery('#result').text(result.status); 
 
    }); 
 
    }); 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> 
 

 
<input type="email" id="email"/> 
 
<button id="submit">Submit</button> 
 

 
<div id-"result"></div>

http://example.com/reset.php

$email = $_GET['email']; 

if (is_valid($email)) { 
    echo json_encode(array('status' => 'Your email is valid')); 
} else { 
    echo json_encode(array('status' => 'Your email is not valid')); 
} 

function is_valid($email) { 
    // do something to validate the email (for ex. check match in database etc) 
    // return true OR false 
}