-1

can you tell me why it says that actual_quote and poster are unidentified indexes please? I have been struggling with this for an hour.

Heres the form where they're getting the values

    <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>

And then here's where the php is grabbing the values and displaying them on the page, the are both showing this error

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

and vice-versa for poster

 <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>

Please help! I am stumped. Thanks in advance, -Connor

CodeZombie
  • 5,367
  • 3
  • 30
  • 37
  • 1
    check with isset http://in2.php.net/isset first before checking if its empty – Prashank May 18 '14 at 02:03
  • Is the second file question.php? – anthonygore May 18 '14 at 02:18
  • Running this code as is doesn't produce that error. Can you provide the full code? Also, you have invalid attributes in your form. "form" in the form tag, and "action" in the input tags are not valid and do nothing. Can you further explain your intentions here? – anthonygore May 18 '14 at 02:28
  • CBRoe what? and anthonygore & Prashank thanks! I will check those out when I get home and get back to you! – user3630438 May 18 '14 at 02:53

2 Answers2

0
<?php $actual_quote = (isset($_GET['actual_quote']) ? $_GET['actual_quote'] : ''); ?>
<div class="top-submit"><?php echo '&#8220;' . $actual_quote . '&#8221;'; ?>
Tanatos
  • 1,857
  • 1
  • 13
  • 12
0

Change the empty() function call for isset().

Maxi Capodacqua
  • 303
  • 1
  • 15