Note that there are some explanatory texts on larger screens.

plurals
  1. PORating on Radio button is not stored
    text
    copied!<p>I have a comment BOX, which has 5 fields, one is name, email, RATE, comment, articleid.</p> <p>Rate field is a radio type, which has 5 radio buttons with value 1,2,3,4,5. IF someone click on rate my product and it should save the rated value in databse. I'm using RATE as INT in database, It stores 0 in it, If i use RATE as TEXT in database, it stores "on" in database. It is not storing rating values like 1,2,3,4,5.</p> <p><strong>My form Code</strong></p> <pre><code>&lt;form action="manage_comments.php" method="post"&gt; &lt;span class="rating"&gt; &lt;input type="radio" class="rating-input" id="rate" name="rate" value="1"&gt; &lt;label for="rating-input-1-5" class="rating-star"&gt;&lt;/label&gt; &lt;input type="radio" class="rating-input" id="rate" name="rate" value="2"&gt; &lt;label for="rating-input-1-4" class="rating-star"&gt;&lt;/label&gt; &lt;input type="radio" class="rating-input" id="rate" name="rate" value="3"&gt; &lt;label for="rating-input-1-3" class="rating-star"&gt;&lt;/label&gt; &lt;input type="radio" class="rating-input" id="rate" name="rate" value="4"&gt; &lt;label for="rating-input-1-2" class="rating-star"&gt;&lt;/label&gt; &lt;input type="radio" class="rating-input" id="rate" name="rate" value="5"&gt; &lt;label for="rating-input-1-1" class="rating-star"&gt;&lt;/label&gt; &lt;/span&gt; &lt;input type='hidden' name='articleid' id='articleid' value='&lt;?php echo $_GET["id"]; ?&gt;' /&gt; &lt;input type="submit" name="submit" value="Publish Now"&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p><strong>My php Code</strong></p> <pre><code>&lt;?php if( $_POST ) { $con = mysql_connect("localhost","asfi","asfi"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("aw-tech", $con); $post_rate = (isset($_POST['rate'])) ? $_POST['rate'] : ''; $articleid = (int)isset($_GET['id']); if(!is_numeric($articleid)) die('invalid article id'); $sql="INSERT INTO `aw-tech`.`comment` (cid, name, email, website, comment, timestamp, rate, articleid) VALUES (NULL, '$_POST[name]', '$_POST[email]', '$_POST[website]', '$_POST[comment]', CURRENT_TIMESTAMP, '$post_rate', ".$articleid.")"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Comment Saved"; mysql_close($con); } ?&gt; </code></pre> <p>Secondly My articleid saves always 0.. my page id is .php?id=49 , it is 49 but if i made comment on that page, It saves my article ID always 0.</p> <p><strong>articleid &amp; rate Both are INT in database, I have used them as TEXT too in database but didn't work</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload