Php身份不明的索引

时间:2014-05-18 02:01:01

标签: php html

你能告诉我为什么说real_quote和poster是不明的索引吗?我一直在努力奋斗一个小时。

这是他们获得价值的形式

    <form name = "quoted" form action = "question.php" method="get">
    <input id = "poster" type="text" name="poster" required="required" placeholder = "Credited Individual.">     
    <br>
    <textarea class = "actual_quote" name = "actual_quote" required="required" placeholder = "Write the question here!"></textarea>
    <br><br><br>

    <div class = "checkboxes" required="required">
        <h3 style = "margin-top:-20px;">Please select one catagory that the quote falls into.</h3>
        <label for="x"><input type="radio" name="x" value="stupid" id = "x" checked="checked" action = "stupid.php" /><span>stupid</span></label>
        <br>
        <label for="x"><input type="radio" name="x" value="stupider" id = "x" action = "stupider.php" /><span>stupider</span></label>
        <br>
        <label for="x"><input type="radio" name="x" value="stupidest" id = "x" action = "stupidest.php" /><span>stupidest</span></label>
    </div>

    <input id = "submit1" type="submit"><br>
 </form> 
<div class="wrapper">
<div class="submissions">
    <div class="logo-logo"><h2>Quotr.</h2>
<div class="checkboxes"><?= !empty($_GET['x']) ? $_GET['x'] : '' ?>
</div>

    </div>

然后在这里,php正在抓取值并在页面上显示它们,这两者都显示此错误

Notice: Undefined index: actual_quote in the index of the file on line 47
Call Stack
Time    Memory  Function
1   0.0004  254200  {main}( )   

反之亦然海报

 <div class="top-submit"><?php echo '&#8220;' . (!empty($_GET['actual_quote']) ? $_GET['actual_quote'] : '') . '&#8221;'; $actual_quote = isset($_GET['actual_quote']) ?: false;?>
  </div>
  <div class="poster"><?php echo "-" .  (!empty($_GET['poster']) ? $_GET['poster'] :''); $poster = $_GET['poster']; $poster = isset($_GET['poster']) ?: false;?>
  <div class = "like">
  <a href = "javascript:countClicksLike();" class = "btn btn-large" style = "color:green;">Like</a>
  <p id = "like" style = "color:green;">0</p>
  </div>
  <div class = "dislike">
  <a href = "javascript:countClicks();" class = "btn btn-large" style = "float:right; color:red;">Dislike</a>
   <p id = "dis" style = "color:red;">0</p>
    </div>
     </div>

请帮忙!我很难过。 提前致谢, -Connor

2 个答案:

答案 0 :(得分:0)

<?php $actual_quote = (isset($_GET['actual_quote']) ? $_GET['actual_quote'] : ''); ?>
<div class="top-submit"><?php echo '&#8220;' . $actual_quote . '&#8221;'; ?>

答案 1 :(得分:0)

更改isset()的empty()函数调用。

相关问题