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
https://forums.phpfreaks.com/topic/68685-solved-isset-is_null/
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
https://forums.phpfreaks.com/topic/68685-solved-isset-is_null/#findComment-345243
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.