Php 使用表单输入从另一个URL获取数据并读取该数据

Php 使用表单输入从另一个URL获取数据并读取该数据,php,jquery,datepicker,get,Php,Jquery,Datepicker,Get,我正在尝试做一些我认为应该相对简单的事情,但我不确定具体如何去做,尽管通过大量的搜索和示例,我仍然不确定如何去做 我有一个表单,它有一个日期输入字段和一个7/14天选择器,当使用更改日期或天数时,它应该查询一个单独的URL,然后返回结果 我的问题是: 如何在表单中选择日期/天数,但读取URL,而不是重定向用户,而是刷新页面以响应读取URL的结果 我用一个简单的例子来说明我的意思: <head> <link rel="stylesheet" href="//code.jquery

我正在尝试做一些我认为应该相对简单的事情,但我不确定具体如何去做,尽管通过大量的搜索和示例,我仍然不确定如何去做

我有一个表单,它有一个日期输入字段和一个7/14天选择器,当使用更改日期或天数时,它应该查询一个单独的URL,然后返回结果

我的问题是:

如何在表单中选择日期/天数,但读取URL,而不是重定向用户,而是刷新页面以响应读取URL的结果

我用一个简单的例子来说明我的意思:

<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>$( function() { $( "#datepicker" ).datepicker(); } ); </script>
</head>
<body>

<?php
// Example fully formatted URL 
http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=2017-06-23&days=7
// http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=[DATESELECTED]&days=[DAYSSELECTED]
?>

<form action="http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&" method="GET">
<input class="datepicker" type="text" id="datepicker" name="date" value="">
<select><option value="7" id="days" name="days">7 days</option><option value="14">14 days</option></select>
<input type="hidden" name="c" value="3" /> 
<input type="submit" /> 
</form>
</body>

<?php
// Read contents of the URL
// dateselected = datepicker output
//$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $days);
// Display contents of the URL, i.e.

echo '<hr>';
echo 'Show example output that we are trying to achieve using above 
selection but with defaults of date today and days of 7.';
echo '<br /><br />';
$dateselected = date('Y-m-d');
$daysselected = '7';
$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected);
echo $angelfish;

//At this point we'll format nicely with coloured rows, etc
?>
</body>
<pre>Please use below code <?php
$dateselected = date('Y-m-d');
$daysselected = '7';
if(isset($_POST['date']) && isset($_POST['days'])){
    $dateselected=date('Y-m-d',strtotime($_POST['date']));
    $daysselected = $_POST['days'];
}
?>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>$( function() { $( "#datepicker" ).datepicker(); } ); </script>
</head>
<body>

<?php
// Example fully formatted URL 
http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=2017-06-23&days=7
// http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=[DATESELECTED]&days=[DAYSSELECTED]
?>

<form name="form1" method="POST">
<input class="datepicker" type="text" id="datepicker" name="date" value="">
<select name="days"><option value="7" id="days" name="days">7 days</option><option value="14">14 days</option></select>
<input type="hidden" name="c" value="3" /> 
<input type="submit" /> 
</form>
</body>

<?php
// Read contents of the URL
// dateselected = datepicker output
//$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $days);
// Display contents of the URL, i.e.

echo '<hr>';
echo 'Show example output that we are trying to achieve using above 
selection but with defaults of date today and days of 7.';
echo '<br /><br />';
echo 'http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected."<bR>";
 $angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected);
echo $angelfish;

//At this point we'll format nicely with coloured rows, etc
?>
</body></pre>
有人能给我指出正确的方向吗

非常感谢,


罗伯

杰克逊,太棒了,非常感谢,我印象深刻。杰克逊,太棒了,非常感谢,我印象深刻。