【发布时间】:2015-04-04 20:16:27
【问题描述】:
大家好,对不起,但我只是 php、mysql 的初学者……我正在开发问答网站,我有所有问题的页面(Q.php)和显示特定问题的页面(QR.php)并得到根据通过 url 从 Q.php 发送的数据的信息($_GET['start'] 我也有页面来确认答案已经提交....但是从 get 方法输入 id 和来自的消息时出现错误发布方法...任何答案将不胜感激
Q.php
<?php
include("pagination.php");
if(isset($res))
{
while($result = mysql_fetch_assoc($res))
{
echo '<div class="shop-item">' ;
echo ' <div class="price">' ;
echo $result['Inquirer'] ;
echo ' </div>' ;
echo ' <div class="price">' ;
echo $result['question'] ;
echo ' </div>' ;
echo ' <div class="actions"> ';
echo '<input type="button" class="btn btn-large " value="More Info" onclick="window.location=\'QR.php?start=' . urlencode($result['id']) . ' \';" />';
echo '</div> ';
echo ' </div> ';
}
}
?>
QR.php
<form action="QRR.php" method="POST">
<div class="blog-post blog-single-post">
<div class="single-post-title">
<h2>Post Your Answer</h2>
</div>
<div align="Right">
<textarea class="form-control" rows="4" name ="answer" id="Test">
</textarea>
<br>
<div class="actions">
<?php echo '<input type="button" class="btn btn-large " value="Post Answer" onclick="window.location=\'QRR.php?start=' . urlencode($_GET['start']) . ' \';" />'; ?>
</div>
</div>
</div>
</form>
QRR.php
<?php
// variables
$answer=$_REQUEST['answer'];
require ("coonection.php");
$FURL = $_REQUEST['hi'];
//query
$query = "INSERT INTO `answers`(`answer_id`, `question_id`, `answer`, `answerer`, `rate`, `dnt`) VALUES ('','$FURL','$answer','ahmed','',CURRENT_TIMESTAMP)";
$data=mysql_query($query) or die(mysql_error());
if($data)
{
echo "Your Questions Has Been Successfully Added ";
}
?>
如果我删除了将 hi 从 QR 传递到 QRR 答案存储 //$answer
如果我从文本区域中删除了存储答案,则来自 url 的 id 将被删除 //$FURL
【问题讨论】:
-
当人们投票否决您的问题但不说明原因时,您不讨厌它吗?我会投票赞成。他们可能投了反对票,因为您不能同时使用 POST 和 GET。
-
完全不清楚。尝试指出代码中出现问题的位置?
-
你绝对可以同时使用get和post。我一直都这样做。例如..通过post提交表单时,您可以使用参数设置url,使其成为get。但是,如果您要提交表单。您可能没有设置要获取的输入和要发布的输入。
-
我在 $answer=$_REQUEST['answer']; 行中的 QRR.php 中有错误@anantkumarsingh 泰
-
@AdamJosephLooze 或者可能会:D 我做到了兄弟