Everything seems to work but the user_id field in the pictures table populates with the numeric value 0
I test the session variable and it prints out exactly what it should so don't know what's going on.
any help appreciated,
<?php
require_once('auth.php');
include("config.php");
$lname = $_SESSION['SESS_LAST_NAME'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$query = "INSERT INTO pictures (file_name, user_id, public, default_pic) VALUES ('$target_path', '$lname', 'yes', 'yes')";
if (mysql_query($query)) {
echo "inserted successfully <br> redirecting to results in (2) Seconds";
echo "<meta http-equiv=Refresh content=2;url=edit-member.php>";
} else {
echo "Something went terribly wrong!! <br>redirecting to results in (2) Seconds " . mysql_error();
// echo "<meta http-equiv=Refresh content=2;url=edit-member.php>";
}
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
//testing session variable data
<?php echo $lname;?>

New Topic/Question
Reply




MultiQuote




|