at last i got the checkboxes to work and add to database but the only this i need advice on if i refresh the page the selected items disappear how can i solve this the

php file is as follows


$check_exist_qry="select * from interests";
if($total_found >0)

    $all_interests_value = implode(",",$_POST['interests']);
    if($total_found >0)
        $upd_qry="UPDATE interests SET interest_name='".$all_interests_value."'";

        $ins_qry="INSERT INTO interests(interest_name) VALUES('".$all_interests_value."')";
if (!empty($_POST['submit'])) {
echo "<ul>";
foreach ($_POST['interests'] as $value) {
echo "<li>$value</li>";
echo "</ul>";
} else {
echo "none";

what selected items? i dont understand the question. If you need to save info across refreshing you can use $_SESSION

Member Avatar

As TobyITguy says use session to propagate between pages. However, I see that you are using a vanilla extract() for $_POST data. I believe the danger of this was pointed out to you in a previous thread, but you have not addressed it. And you're still referencing $_POST vars after the extract() method. So what's the point? The extract() method could be a problem as it overwrites variables witht he same name by default. Have a look at the various flags that you could use to prevent a malicious user from posting dodgy POST 'keys'. Flags like EXTR_PREFIX_ALL may be useful.

ive noticed the post and removed extract() off and have been trying sessions most of day and i am still getting issues on after i submit the data i get

echoed through but if i refresh i get

none echoed through

i have the sessions like below


if(isset($_REQUEST['option1']) && $_REQUEST['option1']=="option1"){
       $option1 = $_POST['option1']; // check box value
  if(isset($_REQUEST['option2']) && $_REQUEST['option2']=="option2"){
       $option2 = $_POST['option2']; // check box value
       if(isset($_REQUEST['option3']) && $_REQUEST['option3']=="option3"){
       $option3 = $_POST['option3']; // check box value
       if(isset($_REQUEST['option4']) && $_REQUEST['option4']=="option4"){
       $option4 = $_POST['option4']; // check box value
       if(isset($_REQUEST['option5']) && $_REQUEST['option5']=="option5"){
       $option5 = $_POST['option5']; // check box value
       if(isset($_REQUEST['option6']) && $_REQUEST['option6']=="option6"){
       $option6 = $_POST['option6']; // check box value
       if(isset($_REQUEST['option7']) && $_REQUEST['option1']=="option7"){
       $option7 = $_POST['option7']; // check box value

i dont know if im doing this bit right as im totally new to sessons and even after i did this nothing is saving i have also put session_start(); on both the file where the form is and also there file where the code is sat

i think i sussed it ill update tomorrow