Jump to content

[SOLVED] isset, is_null ??


director87

Recommended Posts

I have a simple form that allows a user to update their information, on the same form it allows the user to update their photo (although it's not obligatory). My uploading function returns an error when the user hasn't opted to change their photo, however, I don't know how to go about this..........

 

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
	if(is_null ($_FILES['imagen'])) { 
		$imagen = $row_Recordset1['imagen'];  // supplies the form with the original photo
	} else {
                        $imagen=subir($image);    // supplies the query with the new photo 
		}
$colaborador=$_POST['colaborador'];
$pk=$_POST['hiddenField'];
  $updateSQL = sprintf("UPDATE colaboraciones SET imagen='$imagen', colaborador='$colaborador' WHERE pk='$pk';");

  mysql_select_db($database_connect, $connect);
  $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());

 

I know I'm doing this very backwards and probably harder than it needs to be, but for right now I'd be content with getting this working.

 

Thanks for any and all help!

Link to comment
Share on other sites

Just put it ina an if statement

 

just use an !

 

if(!isset($uploadedimg)){

supply old photo

} else {

add new image

}

 

You could however just ignore the processing completely ie not supply the old image again.  Not too much of an issue but just extra load on the server.  But as you said thats how you do it the way you wan.  replace is_null with !

 

Thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.