Forum Moderators: coopster

Message Too Old, No Replies

upload a picture (for first time) in an update file

pictures photo update file database profile dutch

         

Gust

1:48 pm on Sep 2, 2008 (gmt 0)

10+ Year Member



ow can you upload a picture in a update page?
- Before, you can register with a little profile in the first page, without pictures
- Next, you can UPDATE your profile with more specifications, with pictures

But I have a problem. My script doesn't work

This is the script:
<?php

// variabelen initialiseren:
$username = "secret";
$password = "secret";
$host="localhost";
$dbnaam="secret";

$db=mysql_connect($host, $username, $password) or die (mysql_error());
mysql_select_db($dbnaam, $db) or die (mysql_error());

//gegevens doorgegeven door de vorige pagina
$id = $_GET["id"];

// verbinding met database invoegen
//include("inc_connect.php");
// controleren of pagina zichzelf heeft aangeroepen
// via hidden-field uit het formulier
if (isset($_POST["bevestiging"])){

mysql_query("INSERT INTO gaz_main_algemeen (``,`file1',`file2',`file3`,'file4') VALUES('','$_FILES[0]','$_FILES[1]','$_FILES[2]','$_FILES[3]')");
move_uploaded_file($_FILES["pictures"]["tmp_name"], "images/". mysql_insert_id() . ".ext");

/*
if ((($_FILES["file"]["type"] == "image/gif")
¦¦ ($_FILES["file"]["type"] == "image/jpeg")
¦¦ ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("images/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"images/" . $_FILES["file"]["name"]);
echo "Stored in: " . "images/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
*/


// query samenstellen

$query="UPDATE gaz_main_algemeen SET
Name = '". $_POST["Name"] ."',
pass1 = '". $_POST["pass1"] ."',
pass2 = '". $_POST["pass2"] ."',
wachtwoord = '". $_POST["wachtwoord"] ."',
file1 = '". $_FILES["file1"]['tmp_name'] ."',
file2 = '". $_FILES["file2"]['tmp_name'] ."',
file3 = '". $_FILES["file3"]['tmp_name'] ."',
file4 = '". $_FILES["file4"]['tmp_name'] ."',
WHERE id='" .$_POST["id"] ."'";

$result = mysql_query($query) or die ("FOUT: " . mysql_error());

if ($result){
echo ("UW id-nummer " .$_POST["id"] . " is bijgewerkt<br>\n");
echo ("Klik na het terugkeren op vernieuwen om de veranderingen te zien.<br><br>\n");
echo ("<a href='javascript:history.back();'>Terug</a>");
}
}else{
// pagina heeft zichzelf nog niet aangeroepen,
// formulier tonen om gegevens te bewerken
$query="SELECT * FROM gaz_main_algemeen WHERE id='" . $_GET["id"] ."'";
$result = mysql_query($query) or die ("FOUT: " . mysql_error());
?>
<html>
<head>
<title></title>
</head>

<body>

<?php
while (list($ID, $Name, $pass1, $pass2, $wachtwoord, $file1, $file2, $file3, $file4, $enzovoort) =

mysql_fetch_row($result)){
$nam=$Name;
$pss1=$pass1;
$pss2=$pass2;
$wawo=$wachtwoord;
$fl1=$file1;
$fl2=$file2;
$fl3=$file3;
$fl4=$file4;
enzovoort
}?>

<form name="form1" action="<?php echo($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data" method="post">

<input type="hidden" name="id" value="<?php echo($_GET["id"]);?>">

<label for="file"></label>
<input type="file" name="file" id="file" />
<br />
<input type="file" name="file" id="file" />
<br />
<input type="file" name="file" id="file" />
<br />
<input type="file" name="file" id="file" />


<input type="Submit" value="Update" name="bevestiging">
<input type="Button" value="Back" onClick="javascript:history.back(-1);">

</form>

<?php
// else-blok correct afsluiten
}
?>
</body>
</html>

I don't now what's wrong?

eelixduppy

5:45 am on Sep 15, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld!

Are you getting any errors in your error log from this script? Please check and get back to us.