Hello again everyone .
i am new to PHP but steadily improving my skills. i am building my first application and hope to complete it within a week.
i have two questions to ask. But before i start , i first i wish to thank everyone at sitepoint- particularly Anthony Sterling for their kind support and help.
QUESTION ONE
HOW TO MAKE MULTIPLE CHECKBOX VALUES IN A FORM STICKY
i am building a sticky multi checkbox value for a form.
i have adapted a function that was previously given to me at sitepoint but i can’t seem to get it to work.
$jobs = '';
if(isset($_POST['submit']))
{
require_once ('db_fns.php'); // Connect to the db.
$job_sought = $_POST['job_sought'];
foreach ($job_sought as $job)
{$source .= $jobs.", ";}
$jobs_sought = substr($source, 0, -2);
$q3 = "INSERT INTO typeworksought ( user_id, job_sought )
VALUES ( '$id','$jobs_sought' )";
$R3 = mysqli_query ($dbc, $q3); // Run the query.
}
<form action= " "
method="post" name="form1" >
$job = 'job';
function selected($job){
if(empty($_POST['job'])){
return;
}
if(!is_array($_POST['job'])){
return;
}
if(!in_array($job, $_POST['job'])){
return;
}
return 'selected="selected"';
}
if(isset($_POST['job_sought'])){
echo
' <input type="checkbox" name="job_sought[]" value= "'.$job.'"
'.selected($job);' /> job' ;
}
else
{
echo '<input type="checkbox" name="job_sought[]" value="job" /> job';
}
</form>
Two questions regarding my script.
1; any ideas why it is not sticky.
2; is there a better formula for a checkbox sticky form. my concern with my function is that it will be cumbersome if i have many checkboxes in a category. it will means that i will have to draft the same function for each of the checkboxes.
i want to insert all the full values of the submitted checkboxes into the mysql database so that those values can be indexed and searched upon later on
QUESTION TWO;
How do i maintain a session ID in non PHP pages
i have build a website comprising php and html pages. for all the PHP pages i have placed a
session_start();
at the top of the page.
i did this to maintain a session ID for the user. however, the site also contains non php pages, i.e html. the problem is that if a user goes to the Html page and then want to come back to the php page later on they will lose their session Id.
is there a way that i can maintain their session ID even when they are in non php pages? is it possible? or most i convert all the pages to PHP.
thank you everyone for your kind assistance.
sweet thanks
Andreea