header

Many hours on social network and im not a programmer… Hit a snag and tired of googling and searching Following code works except for the last step which is the header back to the profile page IN TS I have put the full url in which copied and pasted works One does have to be logged in … There are errors except i have gotten header already sent a few times.

[php]<?php
session_start();
include_once (‘includes/connect.php’);
$log_user_id = preg_replace(’#[^0-9]#’, ‘’, $_SESSION[‘uid’]);
$username = $_SESSION[‘owner’];
$fileName = $_FILES[“uploaded_file”][“name”]; // The file name
$fileTmpLoc = $_FILES[“uploaded_file”][“tmp_name”]; // File in the PHP tmp folder
$fileType = $_FILES[“uploaded_file”][“type”]; // The type of file it is
$fileSize = $_FILES[“uploaded_file”][“size”]; // File size in bytes
$fileErrorMsg = $_FILES[“uploaded_file”][“error”]; // 0 for false… and 1 for true
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
// START PHP Image Upload Error Handling --------------------------------------------------

if (!$fileTmpLoc) { // if file not chosen
echo “ERROR: Please browse for a file before clicking the upload button.”;
exit();
} else if($fileSize > 5242880) { // if file size is larger than 5 Megabytes
echo “ERROR: Your file was larger than 5 Megabytes in size.”;
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) {
// This condition is only if you wish to allow uploading of specific file types
echo “ERROR: Your image was not .gif, .jpg, or .png.”;
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if ($fileErrorMsg == 1) { // if file upload error key is equal to 1
echo “ERROR: An error occured while processing the file. Try again.”;
exit();
}
// END PHP Image Upload Error Handling ---------------------------------
// Place it into your “uploads” folder mow using the move_uploaded_file() function
$moveResult = move_uploaded_file($fileTmpLoc, “members/$username/$fileName”);
// Check to make sure the move result is true before continuing
if ($moveResult != true) {
echo “ERROR: File not uploaded. Try again.”, $fileName;
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
}
// ---------- Include Adams Universal Image Resizing Function --------
include_once(“scripts/avatar_sizecrop.php”);
$target_file = “members/$username/$fileName”;
$resized_file = “members/$username/$fileName”;
$wmax = 600;
$hmax = 300;
ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);
header(‘Location: https://libertarian-forum.com/PFL/profile.php?user=karyoker’);
$query = $db->query(“UPDATE members SET banner=’$fileName’ WHERE username=’$username’ LIMIT 1”);

exit();
?>[/php]

the header line should be after the query i moved it trying to get it to work.

Have a look again at the PHP Manual: header().

Sponsor our Newsletter | Privacy Policy | Terms of Service