Creating an isset if function using php to avoid and update if the input is empty for a MYSQL update -
Hello I am new to php and I have created update page for content management system. I have a picture upload in this case. I have other inputs that contain text and I can fill them up and fix my form and work well because the user can see what has been recorded already but the value of the filename for the photo It can not be that if the user does not take the picture from the directory, then it will update the picture with zero. I think I have an early work that says if the file (input) is left blank then do not update this field and use it for whatever is already in the database. It will still be, and if the user has changed it, then this will change; Or if they want to leave it, their picture will not leave empty. Hope is made of flax.
This time my coding is for the form:
& lt; P & gt; Photo: & lt; / P & gt; & Lt; Input type = "hidden" name = "MAX_FILE_SIZE" value = "350000" & gt; & Lt; Input type = "file" name = "photo" />
My PHP code for my updates is below, if the update button is pressed:
$ con = mysql_connect ("localhost", "** ** ** "," ******** "); If (! $ Con) {dead ('Could not connect:' Mysql_error ()); } Mysql_select_db ("*******", $ Conn); // After issuing it, "user" has suppressed the "update" button, if (isset ($ _ POST ['update'])) {// assign form input $ name = $ _POST ['nameMember' ]; $ Position = $ _POST ['bandmember']; $ Pic = $ _POST ['photo']; About $ = $ _POST ['Member'] about ';; $ Band = $ _POST ['other band']; // Add member in database $ result = mysql_query ("UPDATE dbProfile SET nameMember = '. $ Name.' ', Bandmember ='" $ position. "', Photo ='". $ Pic. "', AboutMember =' ' About $. '', Other Band = ''. $ Band. '' WHERE id = '". $ Id."' "); Mysql_close ($ thief); Header ("location: list member.fp"); Go out; } Else {// database result result member data $ result = mysql_query ("SELECT * FROM dbProfile WHERE id = '. $ Id." "" "); While ($ line = mysql_fetch_array ($ result)) {$ name = $ row ['nameMember']; $ Position = $ line ['bandmember']; $ Pic = $ line ['photo']; About $ $ = $ line ['aboutMember']; $ Band = $ line ['other band']; }} Mysql_close ($ con); ? & Gt;
If you can help, I will be very happy and cheerful.
You must use for uploaded files For more information, see the PHP manual.
Comments
Post a Comment