从其他网站获取回复

时间:2017-04-24 18:53:29

标签: php get

我希望代码能够在另一个网站上给我表单的响应,并在代码的同一页面中获得响应,例如

有一个叫做的字段 “把你的电子邮件重置密码” “”

我的想法是这个

$url = 'http://example.com/reset.php';
&email = a@a.com;

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

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

例如

您的电子邮件不存在

并确定我想要所有这些而不进入上面的网站我只是想知道当我发送电子邮件时表格的响应是什么

我希望你有我的想法 对不起我的英语。

1 个答案:

答案 0 :(得分: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
}
相关问题