0

hya all i have sorted the checkbox group out and its echoing through ok but its also echoing through userid, username twice and email address when all i want is to echo options ticked any ideals of what can be causing this please
php block at top of page:

<?php
ini_set('session.cookie_lifetime', 86400);
ini_set('session.gc_maxlifetime', 86400);
session_start();
//print_r($_SESSION);
include("config/db_connect.php");
//echo "<pre>";
//echo $all_interests_value = implode(",",$_POST);
//print_r($_POST);
if (isset($_POST['submit'])) {
@$_SESSION["option1"]=$_REQUEST['option1'];
@$_SESSION["option2"]=$_REQUEST['option2'];
@$_SESSION["option3"]=$_REQUEST['option3'];
@$_SESSION["option4"]=$_REQUEST['option4'];
}
$check_exist_qry="select * from interests";
$run_qry=mysqli_query($conn,$check_exist_qry);
$total_found=mysqli_num_rows($run_qry);
if($total_found >0)
{
    $my_value=mysqli_fetch_assoc($run_qry);
    $my_stored_interests=explode(',',$my_value['interest_name']);
}


if(isset($submit))
{
    $all_interests_value = implode(",",$_POST);
    if($total_found >0)
    {
        //update
        $upd_qry="UPDATE interests SET interest_name='".$all_interests_value."'";
        mysqli_query($conn,$upd_qry);

    }
    else
    {
        //insert
        $ins_qry="INSERT INTO interests(interest_name) VALUES('".$all_interests_value."')";
        mysqli_query($conn,$ins_qry);
    }
}
?>

The html block:

<html> <head> <title></title> </head> <body> <?php
if (isset($_POST['submit'])) {
echo "<ul>";
foreach ($_SESSION as $value) {
if($value!="")
{
echo "<li>$value</li>";
}
}
echo "</ul>";
} else
{
echo "<ul>";
foreach ($_SESSION as $value) {
if($value!="")
{
echo "<li>$value</li>";
}
}
echo "</ul>";
}
?> </body> </html>

Any help would be much appreicated p.s sorry for long coding x

3
Contributors
6
Replies
35
Views
1 Year
Discussion Span
Last Post by ryantroop
0

Personally, I don't think you should be using the sesson variable like this. It is likely the root of your problem as well.

If you need a "stateful" system, that's what the database is for - even for temporary things. It's ok to delete from the database.

0

he didnt put the session variable in i paid a freelancer to sort it so would it be safe to remove the session variables hun

0

i have the items going to the database but the profile page isnt picking it up although ive put to fetch it from database like the following:

php section

// Fetch Interests for profile interests
$interest_name = $fetch_interests['interest_name'];

$interests_query        = mysqli_query($conn,"select * from interests where user_id = '".$fetch_interests['user_id']."' ");
$fetch_interests        = mysqli_fetch_array($interests_query);

html section

<div class="profl_title"> Interests</div>
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
      <div class="profl_contnt">

      <?php echo $fetch_interests['interest_name'];?>

     <div class="clr"></div>
      </div>
0

he didnt put the session variable in i paid a freelancer to sort it so would it be safe to remove the session variables hun

Who.s he? Confused. This is not your code?? The freelancer did something then "he" did something? WTF?

0

Then you need him to support his code. And not use awful error suppressing for no reason. If that code is producing errors, you got a lot of other things to worry about :-/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.