Why doesnt this file upload script work? (SPOT THE ERROR)
Posted: Tue Nov 14, 2006 2:36 pm
Jcart | Please use
Jcart | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
You may want to copy and past this code into dreamweaver or something. Anyway, this script doesnt work properly. Its ment to check if the users password exists and then if it does update a column in the database for them. After this the user gets forwarded to a page that says "picture updated". When i test the script seems to do its stuff and then send me to the Picture Updated.php page but when i check my database nothing has been entered in the specified column.
Can you spot any errors in this script or anything that could possibly not make it work. Thanx.
The script:
[syntax="php"]if ($PASSWORD == $_POST['MYPASSWORD2'])
{
$file_name = $_FILES['ufile']['name'];
$random_digit=rand(0000,9999);
$new_file_name=$random_digit.$file_name;
$path= "/Uploads/".$new_file_name;
if($ufile !=none)
{
if(copy($_FILES['ufile']['tmp_name'], $path))
{
$_SESSION['op']=$new_file_name;
}
}
$query = "UPDATE table SET SITENAMEIMG1='hi'
WHERE USERNAME=\"" . $_SESSION['USERNAME'] . "\" AND PASSWORD=\"" . $_POST['MYPASSWORD2'] . "\"";
$result = mysql_query($query)
or die("peterpan");
header("location:/Main/Picture Updated.php");
exit();
}
else
{
header("location:/Main/Error Picture.php");
exit();
}Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]