ok so i got a file upload script, it works perfect when i am created a new user and have to upload the image for that new user. but when i use the script to update a current user, like change the image of the current user the file does no upload.
here is the form and what not on the current user.
<?
{
include 'library/config.php';
include 'library/opendb.php';
}
?>
<?
mysql_select_db("$dbname");
?>
<?
$sql = "SELECT * FROM professionals WHERE pro_id = $_GET[id];";
// execute SQL query and get result
$sql_result = mysql_query($sql,$conn)
or die(mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
// Loop through the data set and extract each row in to it's own variable set
while ($row = mysql_fetch_array($sql_result)) {
extract($row);
?>
<form action="proupdate.php" method="POST" name="form1" class="black">
<p>
<input name="pro_id" type="hidden" id="pro_id" value="<?php echo $pro_id; ?>">
<br>
Positon<br>
<select name="pro_positon" id="pro_positon">
<option value="Partners" <?php if (!(strcmp("Partners", $pro_positon))) {echo "selected=\"selected\"";} ?>>Partners</option>
<option value="Associates" <?php if (!(strcmp("Associates", $pro_positon))) {echo "selected=\"selected\"";} ?>>Associates</option>
<option value="Of Counsel" <?php if (!(strcmp("Of Counsel", $pro_positon))) {echo "selected=\"selected\"";} ?>>Of Counsel</option>
<option value="Special Of Counsel" <?php if (!(strcmp("Special Of Counsel", $pro_positon))) {echo "selected=\"selected\"";} ?>>Special Of Counsel</option>
<option value="Technical Staff" <?php if (!(strcmp("Technical Staff", $pro_positon))) {echo "selected=\"selected\"";} ?>>Technical Staff</option>
</select>
</p>
<p><img src="../professionals/<?php echo $pro_pic; ?>" width="148" height="200"><br>
Picture Address
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="900000000000000000000">
<br>
<input name="userfile" type="file" id="userfile" value="<?php echo $pro_pic; ?>" size="60">
</p>
<p>Name<br>
<input name="pro_name" type="text" id="pro_name" value="<?php echo $pro_name; ?>">
</p>
<p>Bio<br>
<textarea name="pro_content" cols="60" rows="8" id="pro_content"><?php echo $pro_content; ?></textarea>
<br>
<input name="add" type="submit" id="add" value="Submit">
<input name="add2" type="reset" id="add2" value="Reset">
</p>
</form>
<?
// End while loop
}
?>
</body>
</html>
<?php
mysql_close($conn);
?>
and here is the page where it does its magic. lol
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Serko & Simon LLP .::. Admin CP</title>
<link href="../styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" style="background-image:url(../images/bgtop.jpg)"><img src="../images/Globe4.jpg" width="589" height="191"></td>
</tr>
<tr>
<td width="20%" height="150" valign="top"><div style="margin-top:5px"><? include('cpnav.php'); ?></div></td>
<td width="80%" valign="top">
<p>
<? ini_set("upload_max_filesize","20M");
if(isset($_POST['add']))
{
include 'library/config.php';
include 'library/opendb.php';
$pro_id = $_POST['pro_id'];
$pro_positon = $_POST['pro_positon'];
$pro_name = $_POST['pro_name'];
$pro_content = $_POST['pro_content'];
$uploaddir = '/home/virtual/site26/fst/var/www/html/professionals/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
/*if (($_FILES['userfile']['type'] != "application/msword") || ($_FILES['userfile']['type'] != "application/pdf")) {
die($_FILES['userfile']['type']);
}*/
echo($_FILES['userfile']['type']);
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
$pro_pic = $_FILES['userfile']['name'];
$query = "UPDATE professionals SET pro_positon='$pro_positon', pro_name='$pro_name', pro_content='$pro_content', pro_pic='$pro_pic' WHERE pro_id='$pro_id'";
mysql_query($query) or die('Error, update query failed, could not connect to database');
//echo "New Alert added \n";
include 'library/closedb.php';
}
?>
</p>
<p>File Updated<br>
Click here to go <a href="professionals.php" class="black">back</a></p></td>
</tr>
</table>
</body>
</html>
everything else updates, like the name and postion and the bio about it, just not the picture, it wont even upload the new picture. so it is something with the file upload.