I am trying to add a new row to a table in my database, there is only two columns in the table and i am using a form to get one of the fields. here is the form i am using
<form action="add_list.php" method="post">
Name: <input type="text" name="listname">
<input type="submit" value="Add List">
</form>
and here is add_list.php
<?php
/* Execute a prepared statement by binding PHP variables */
$username = "mydb";
$password = "mydb";
$member = $_SESSION['SESS_MEMBER_ID'];
$listname = $_POST["listname"];
try {
$dbh = new PDO('mysql:;dbname=mydb', $username, $password);
$sth = $dbh->prepare('INSERT INTO lists VALUES (:member_id, :listname)');
$sth->execute(array(':member_id' => $member, ':listname' => $listname));
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();}
?>
I am currently getting an error on line five
Undefined variable: _SESSION in /home/danu2_cj3/public_html/add_list.php on line 5
how to I identify the session variable?
Here is the part of the login code i have set the session in
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
session_write_close();
header("location: lists.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}