i need to set a session variable when someone submits a form, i was thinking something like onsubmit=""
can any1 help me?
thanks
need to set session variable when submit a form
Moderator: General Moderators
Re: need to set session variable when submit a form
onsubmit is for javascript you need to set the session variable in php.
http://uk2.php.net/manual/en/function.session-start.php
http://uk2.php.net/manual/en/function.session-start.php
Code: Select all
<?php
// page1.php
session_start();
echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: need to set session variable when submit a form
if someone submits a form you follow a very similar approach as panic has suggested - however, you do need to determine whether a form has been submitted:
Code: Select all
if(isset($_POST['submit']))
{
$_SESSION['form_submitted']=1;
}
Re: need to set session variable when submit a form
thanks this helped, i edited it slightly, and it works fine, does the job i need it to
thanks
thanks