PHP / Apache错误:406不可接受
|
所以今天我收到了这个错误,我已经将其缩小到这个问题: 我的网站是我的音乐家页面here.它允许人们进来看我的照片,新闻,我的音乐和我正在玩的事件. 一切都在膨胀,我手动将数据输入MySQL,让它自动提供给主页.现在我正在添加控制面板,以便我可以从Web添加,编辑和删除数据库中的内容. 除了添加/编辑事件的能力之外,一切正常.我把它缩小到我无法输入2个URL或我收到此错误的事实.我需要输入2个网址(一个用于查看活动页面,一个用于购买门票)但我一次输入的数量不能超过1个,是否有任何我可以做的纠正或解决此错误,无论是在apache还是我的码? <?php
$specevlink = "http://facebooklink.com";
$specgigtick = "http://ticketplacelink.com";
?>
<form method="post" action="index.php?page=editgigs">
<table>
<tr>
<td>
Event Page (Link):
</td>
<td style="text-align: left;">
<input type="url" name="giglink" value="<?php echo $specevlink; ?>" />
</td>
</tr>
<tr>
<td>
Event Tickets (Link):
</td>
<td style="text-align: left;">
<input type="url" name="gigtick" value="<?php echo $specgigtick; ?>" />
</td>
</tr>
</table><br />
<input type="submit" name="editgig" value="submit" /><br />
<br />
</form>
编辑: 我正在添加完整的代码行,以便您可以确切地看到我正在使用的代码, 这是step 1的照片 这包含在index.php文件中: <?php
if(isset($_GET["page"])){
$page = $_GET["page"];
} else {
$page = "";
}
if($page === "editgigs"){
include ('inc/logincheck.php');
?>
<div class="label">
EDIT GIGS
</div><br />
<div style="margin: 0 auto; text-align: center; width: 100%">
<form method="post" action="index.php?page=editgigs">
<?php
if(!isset($_POST['selectgigs'])){
if(!isset($_POST['updgigs'])){
?>
Select one of the options below:<br />
<br />
<select name="selgigs" style="max-width: 26%;">
<?php
while($gigsall_data = mysqli_fetch_array($gigsall_query)){
$gigid = stripslashes($gigsall_data['idgigs']);
$gigdate = stripslashes($gigsall_data['date']);
$gigname = stripslashes($gigsall_data['name']);
$gigdate = date('F j,Y',strtotime($gigdate));
?>
<option value="<?php echo $gigid; ?>">
<?php echo $gigdate; ?>: <?php echo $gigname; ?>
</option>
<?php
}
?>
</select><br /><br />
<input type="submit" name="selectgigs" value="Select" /><br />
<br />
<?php
}
}
if(isset($_POST['selectgigs'])){
$gigtoed = trim($_POST['selgigs']);
$specgig_query = mysqli_query($con,"SELECT * FROM `gigs` WHERE `idgigs` = '$gigtoed'") or die(mysqli_error($con));
$specgig_data = mysqli_fetch_array($specgig_query);
$specdate = stripslashes($specgig_data['date']);
$specname = stripslashes($specgig_data['name']);
$specevlink = stripslashes($specgig_data['evlink']);
$specgigtick = stripslashes($specgig_data['ticklink']);
$specnos = stripslashes($specgig_data['noshow']);
if($specnos === '0'){
$noshow = '';
} else {
$noshow = 'checked';
}
?>
<table style="border-spacing: 5px; padding: 10px;">
<tr>
<td>
Past Event?:
</td>
<td style="text-align: left;">
<input type="checkbox" name="nos" <?php echo $noshow; ?> /> Past Event
</td>
</tr>
<tr>
<td>
Date:
</td>
<td style="text-align: left;">
<input type="date" name="gigdate" value="<?php echo $specdate; ?>" required />
</td>
</tr>
<tr>
<td>
Name:
</td>
<td style="text-align: left;">
<input type="text" name="gigname" value="<?php echo $specname; ?>" required />
</td>
</tr>
<tr>
<td>
Event Page (Link):
</td>
<td style="text-align: left; width: 350px;">
<input type="url" name="giglink" style="width: 100%;" value="<?php echo $specevlink; ?>" />
</td>
</tr>
<tr>
<td>
Event Tickets (Link):
</td>
<td style="text-align: left; width: 350px;">
<input type="url" name="gigtick" style="width: 100%;" value="<?php echo $specgigtick; ?>" />
</td>
</tr>
</table><br />
<input type="hidden" name="gigid" value="<?php echo $gigtoed; ?>" />
<input type="submit" name="updgigs" value="Update" /><br />
<br />
<?php
}
if(isset($_POST['updgigs'])){
$newid = trim($_POST['gigid']);
$newdate = mysqli_real_escape_string($con,trim($_POST['gigdate']));
$newname = mysqli_real_escape_string($con,trim($_POST['gigname']));
$newlink = mysqli_real_escape_string($con,trim($_POST['giglink']));
$newtick = mysqli_real_escape_string($con,trim($_POST['gigtick']));
if(isset($_POST['nos'])){
$newnoshow = mysqli_real_escape_string($con,'1');
} else {
$newnoshow = mysqli_real_escape_string($con,'0');
}
echo $newid.' '.$newdate.' '.$newname.' '.$newlink.' '.$newtick.' '.$newnoshow.'<br />';
/*mysqli_query($con,"UPDATE `gigs` SET `date` = '$newdate',`name` = '$newname',`evlink` = '$newlink',`ticklink` = '$newtick',`noshow` = '$newnoshow' WHERE `idgigs` = '$newid' LIMIT 1") or die(mysqli_error($con));*/ //commented for testing
?>
<div style="text-align: center;">
<span class="confirm">
Successfully updated click <a href="index.php?page=events">here</a> to view it!
</span>
</div>
<?php
}
?>
</form>
</div>
<?php
}
仅供参考 – logincheck.php什么都不做,只检查用户是否已登录,如果没有,则将其发送回主页. 如果任何用户输入项以http://或https://开头,则您的网站会产生错误.当我尝试使用以http://开头的链接时,我得到了406 Not Acceptable: http://onkore.us/?blah=http://www.google.com 我试试这个很好: http://onkore.us/?blah=www.google.com 您已经提到过,如果它有多个链接,您就会遇到问题,但是当我尝试使用下面的两个链接时,它很好: http://onkore.us/?blah1=www.google.com&blah2=www.google.com 但是,您可以找到并修复可能特定于您的服务器配置的问题,或者您可以尝试解决此问题. 我不确定这种解决方法是否有帮助,但考虑到http://或https://正在创建问题,我的想法是从用户输入中删除http://和https://.首先,您可能希望尝试将< input type =“url”更改为< input type =“text”,以便不强制执行URL格式.然后,您可以使用Javascript在提交到服务器之前从表单中的用户输入中删除http://和https://的出现.此外,您可以在填充表单值之前从数据中删除这些. 希望这可以帮助 . 正则表达式:How to remove ‘http://’ from a URL in JavaScript (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
