PHP - Multi Image Update If Form Field Not Empty
hi all
i have a problem here, Iv got a form that uploads images to a folder and updates the db with the name of that image, that work ok but if one of the upload field are left blank then the script updates the db with empty values how can i get it to only update the db with only submitted form field data???? here is the form Code: [Select] <?php if (isset($_GET['id'])) { $id = $_GET['id']; } ?> <form action="ud_image.php?id=<? echo "$id"?>" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table class="udp"> <tr> <th>Thumbnail:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 1:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 2:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 3:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 4:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </form> and here is the processing page <?php include("protect/password_protect.php"); error_reporting(E_ALL); include ("../includes/db_config.php"); $con = mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database) or die( "Unable to select database"); $path1= "../thumbnails/".$_FILES['ufile']['name'][0]; $path2= "../images/".$_FILES['ufile']['name'][1]; $path3= "../images/".$_FILES['ufile']['name'][2]; $path4= "../images/".$_FILES['ufile']['name'][3]; $path5= "../images/".$_FILES['ufile']['name'][4]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); copy($_FILES['ufile']['tmp_name'][3], $path4); copy($_FILES['ufile']['tmp_name'][4], $path5); ?> <html> <head> <title>Update Project Images</title> <link rel="stylesheet" type="text/css" href="../../project/backend/style.css" /> </head> <body> <table class="udip"> <tr> <th><? echo "<img src=\"$path1\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path2\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path3\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path4\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path5\" width=\"150\" height=\"150\">";?></th> </tr> <tr> <td><? echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][3]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][4]."<BR/>";?></td> </tr> <tr> <td><?echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][3]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][4]."<BR/>";?></td> </tr> <tr> <td><? echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][3]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][4]."<BR/>";?></td> </tr> </table> </body> </html> <? $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; $filesize4=$_FILES['ufile']['size'][3]; $filesize5=$_FILES['ufile']['size'][4]; if($filesize1 && $filesize2 && $filesize3 && $filesize4 && $filesize5 != 0) { echo "We have recieved your files<p>"; } else { echo "Error in you images check and try again Database has been updated to blank images so no images will be shown on details page."; } $query = "UPDATE $db_table SET thumbnail = '".$_FILES['ufile']['name'][0]."', image1 = '".$_FILES['ufile']['name'][1]."', image2 = '".$_FILES['ufile']['name'][2]."', image3 = '".$_FILES['ufile']['name'][3]."', image4 = '".$_FILES['ufile']['name'][4]."' WHERE id = '".$_GET['id']."'"; if (!mysql_query($query,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> Similar TutorialsWhat I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> Hi i have this simple update form and scrip but somehow it doesnt seem to be update the field on the database can someone help out please. The html form is the second form bellow where the action send to status_update.php HTML FORM Code: [Select] <?php include("../header.html"); ?> <?php include("header_news.html"); extract($_REQUEST,EXTR_SKIP); ?><?php /* print("sfilm_refnum = $sfilm_refnum<BR>"); print("sfilm_addr01 = $sfilm_addr01<BR>"); print("sfilm_postcode = $sfilm_postcode<BR>"); print("Film Client = $fclient<BR>"); */ ?> <form id="search" action="list.php" method="post" name="search"> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td align="right" width="140"></td> <td width="320"><span class="hofblack10"> </span> </td> <td align="center" width="100"><input type="hidden" name="lstart" value="<?php print("$lstart"); ?>" /><input type="hidden" name="lend" value="<?php print("$lend"); ?>" /><input type="hidden" name="lamount" value="<?php print("$lamount"); ?>" /></td> <td align="center" width="100"></td> <td align="right"></td> </tr> </table> </form> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#4050c4"> <tr> <td width="60" class="hofwhite10">action</td> <td width="140"><span class="hofwhite14">DATE</span></td> <td width="80"><span class="hofwhite14">ID</span></td> <td><span class="hofwhite14">News Titile</span></td> <td width="100"><span class="hofwhite14">Status</span></td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table><table width="780" border="0" cellspacing="0" cellpadding="4"><tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> <tr height="0"> <td width="60" height="0"></td> <td width="80" height="0"></td> <td height="0"></td> <td align="right" width="120" height="0"></td> </tr> </table> <?php //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select DATABASE."); $query2="SELECT * FROM news WHERE !(news_status='deleted')"; $result2 = mysql_query($query2) or die("Couldn't execute QUERY - Select NEWS Qty"); $fqty = mysql_num_rows($result2); //SELECT or FIND the same USERNAME $query3="SELECT * FROM news WHERE !(news_status='deleted') ORDER BY news_id DESC"; $result3 = mysql_query($query3) or die("Couldn't execute QUERY - Select NEWS"); while ($row = mysql_fetch_array($result3)) { $news_id = $row['news_id']; $news_title = $row['news_title']; $news_story = $row['news_story']; $news_image = $row['news_image']; $news_image_caption = $row['news_image_caption']; $news_image_link = $row['news_image_link']; $news_date_day = $row['news_date_day']; $news_date_month = $row['news_date_month']; $news_date_year = $row['news_date_year']; $news_status = $row['news_status']; $news_website = $row['news_website']; $news_date_created = $row['news_date_created']; $news_date_modified = $row['news_date_modified']; ?> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td width="60"><span class="hofblack10"> <?php if($news_status=="deleted"){ print("<a class='hifblack10'>deleted</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>edit</a>"); } ?> </span></td> <td width="140"><span class="titlegrey12"> <?php if(!$news_date_day) { echo "00"; } else{ echo $news_date_day; } echo "/"; if(!$news_date_month) { echo "00"; }else{ echo $news_date_month; } echo "/"; if(!$news_date_year) { echo "0000"; }else{ echo $news_date_year; } ?> </span></td> <td width="80"><span class="titlegrey12"><?php print("$news_id"); ?></span> </td> <td><?php if($news_status=="deleted") { print("<class='hofblack10'>$news_title</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>$news_title</a>"); } ?></td> <td width="100"> <form id="list_update" action="status_update.php" method="post" name="list_update"> <select name="newnstatus" size="1"> <option <?php if($row['news_status'] == "") { print("selected"); } ?> selected="selected" value="">Status...</option> <option <?php if($row['news_status'] == "on") { print("selected"); } ?> value="on">On</option> <option <?php if($row['news_status'] == "off") { print("selected"); } ?> value="off">Off</option> <option <?php if($row['news_status'] == "deleted") { print("selected"); } ?> value="deleted">Delete</option> </select> <input type="hidden" name="nstatus" value="<?php echo $row[news_status]; ?>" /> <input type="hidden" name="id" value="<?php echo $row[news_id]; ?>" /> <input type="submit" name="update" value="update" /> </form> </td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table> <?php } mysql_close($connection);//}?> <table width="780" border="0" cellspacing="0" cellpadding="4"> <tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> </table><?php // include("list_navigation.html"); ?> <?php include("../footer.html"); ?> </div></body></html> The action script php Code: [Select] <?php /* echo "fstatus: ".$fstatus."<BR>"; echo "id: ".$id."<BR>"; echo "fclient: ".$fclient."<BR>"; echo "newfstatus: ".$newfstatus."<BR>";*/ //set the date of agreement $timestamp = date('l jS \of F Y h:i:s A'); //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select FILMS DATABASE."); // All appears well, so enter into database $query= "UPDATE news SET news_status = '$newnstatus' WHERE news_id='$id'"; $result = mysql_query($query) or die("could not execute query - Update FILMS Record to DB"); //setup an email to the Admin @ hof, w/o attachment $emailto="xx@xxx.co.uk"; $emailfrom="no-reply@xxxx.co.uk"; $emailsubject="xx Record Updated"; $emailmessage="Hello Registrar\n\n"; $emailmessage.="News ID: ".$id."\n"; $emailmessage.="Updated on: ".$timestamp."\n\n"; $emailmessage.="Status was: ".$nstatus."\n"; $emailmessage.="Status now: ".$newfnstatus."\n"; $emailmessage.="Thank you,\n\n"; $emailmessage.="Web Site ROBOT\n"; $emailmessage.="(Administrator)\n"; $emailmessage.="xxx.co.uk | xxx.biz\n"; $emailmessage.="----------------------------------------------\n"; $emailmessage.="e. http://www.xxx.co.uk/contact.php\n"; $emailmessage.="w. http://www.xxx.co.uk\n"; $emailheader="From: xxx.co.uk<$emailfrom>"; $emailheader .= 'Cc: xxx@xxx.co.uk'."\r\n"; $emailheader .= 'Bcc: xxx@xxxxx.co.uk'."\r\n"; $ok=mail($emailto,$emailsubject,$emailmessage,$emailheader); mysql_close($connection); if ($ok) { header("Location: list.php"); /* Redirect browser */ exit; } else { $errmsg="There was a problem, please try later or telephone us direct."; $errsta="1"; include("edit_error.html"); //echo "<p>Mail could not be sent. Sorry!</p>"; exit; } ?> Thanks in advance Hello All,
Being a newbie at PHP coding I'm at my wits end trying to figure out:
a) how to pull-in values from a delimeted text field (in a MySQL table) and check/select the appropriate checkboxes, based on the values that were stored in the text field,
b) how to write any changes (made by the user) back to the tables' text field.
Note that this is for an "update.php" file/process.
My "create.php" file/process uses the following HTML to display and accept the checkbox values:
<div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F'><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa'><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su'><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M'><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu'><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W'><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th'><span class='no-highlight'>Thu</span></label> </div> </div>And the code (certainly not the best code in the world, but it works) to collect, delemit/concatenate, and save to DB is as follows: if(empty($_POST['limited_time_sale'])) { // echo("You didn't select any weekday."); $selected_lts = ''; $limited_time_sale = ''; } else { $limited_time_sale = $_POST['limited_time_sale']; $N = count($limited_time_sale); $selected_lts = ''; // echo("You selected $N DoW(s): "); for($i=0; $i < $N; $i++) { // echo($limited_time_sale[$i] . " "); if ($i < ($N - 1)) { $selected_lts .= $limited_time_sale[$i] . "-"; } else { $selected_lts .= $limited_time_sale[$i]; } } } if(!empty($selected_lts)) { $limited_time_sale = $selected_lts; }Now, I've figured out how to bring-in, and separate the stored values using the following code, however I have no idea what to do next...in order to have only the approprite boxes checked/selected (in the event that all boxes were not selected during the create stage). $limited_time_sale = isset($values['limited_time_sale']) ? $values['limited_time_sale'] : ''; $checked_lts = explode("-", $limited_time_sale);In my "update.php" file, the HTML for the forms' checkboxes is as follows: <div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F' <?php echo $lts1; ?>><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa' <?php echo $lts2; ?>><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su' <?php echo $lts3; ?>><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M' <?php echo $lts4; ?>><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu' <?php echo $lts5; ?>><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W' <?php echo $lts6; ?>><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th' <?php echo $lts7; ?>><span class='no-highlight'>Thu</span></label> </div> </div>Attached picture shows that selected checkboxes are saved to the text field as/in the format of "F-Sa-Su-M-Tu-W-Th" - if all checkboxes/weekdays were selected....or as "Sa-M-W-Th" - if only Sat, Mon, Wed, and Thu checkboxes were selected Thanks. Attached Files checkbox-Question.png 403.99KB 0 downloads Hi Guys, I want my UPDATE function from the code below to only update those fields that are NOT empty - if they are empty on submit then do not update or change any values from that field. I know that sounds odd, but with my file fields, when I submit to change something else at a later date it will overwrite the photo, download1,2 & 3 values and as a result I loose my files from the mysql table. Cheers, S <?php include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { //Photo & Document Upload Upload $timestamp_photo = time(); $timestamp_download1 = time(); $timestamp_download2 = time(); $timestamp_download3 = time(); //This is the directory where the files will be saved //Photos $photo_target = "images/"; $photo_target = $photo_target .$timestamp_photo. basename( $_FILES['photo']['name']); //Documents $download_target = "documents/"; $download_target1 = $download_target .$timestamp_download1. basename( $_FILES['download1']['name']); $download_target2 = $download_target .$timestamp_download2. basename( $_FILES['download2']['name']); $download_target3 = $download_target .$timestamp_download3. basename( $_FILES['download3']['name']); //This gets all the other information from the form $photo = ($_FILES['photo']['name']); $download1 = ($_FILES['download1']['name']); $download2 = ($_FILES['download2']['name']); $download3 = ($_FILES['download3']['name']); //Pause Photo/Document Upload foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql= "UPDATE `ter` SET `Ter` = '{$_POST['Ter']}' , `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' , `Theme` = '{$_POST['Theme']}' , `LocalInfo` = '{$_POST['LocalInfo']}' , `BranchInfo` = '{$_POST['BranchInfo']}' , `photo` = '$timestamp_photo{$_FILES['photo']['name']}' , `download1` = '$timestamp_download1{$_FILES['download1']['name']}' , `download1name` = '{$_POST['download1name']}' , `download2` = '$timestamp_download2{$_FILES['download2']['name']}' , `download2name` = '{$_POST['download2name']}' , `download3` = '$timestamp_download3{$_FILES['download3']['name']}' , `download3name` = '{$_POST['download3name']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); //Unpause Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $photo_target)) { echo "<br />The file ".$timestamp_photo. basename( $_FILES['photo']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download1']['tmp_name'], $download_target1)) { echo "<br />The file ".$timestamp_download1. basename( $_FILES['download1']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download2']['tmp_name'], $download_target2)) { echo "<br />The file ".$timestamp_download2. basename( $_FILES['download2']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download3']['tmp_name'], $download_target3)) { echo "<br />The file ".$timestamp_download3. basename( $_FILES['download3']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload echo (mysql_affected_rows()) ? "<br />Edited Branch.<br />" : "<br />Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?> Code: [Select] $new_array2=array_diff($my_array,$itemIds); $updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE $new_array2 = field_item_id_value"); "$new_array2" has only 12 digit numbers for each item in the array, and I want to match them to the "field_item_id_value" field in the table, updating the "field_expire_value" field for the record where they match. I know I am close because the UPDATE code works before I add the WHERE statement (it of course adds '666' to EVERY field, but for a noobie it's a start!). have 2 scripts one that allows me to insert and upload image and one that allows me to delete and remove image so i was thinking in mix both together so it would be like this first the delete image in an if statment then close } and then { an insert image but with an update mysql query} i am trying to do a modify form where user can modify the data so i will need to update the image on the directory so with both delete and insert would it do the job??? <?php define('ROOT_DIR', './'); define('PROPER', TRUE); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); // No album id has been selected if (isset($_GET['drivers'])) { // get the image file name so we // can delete it from the server $sql = "SELECT id, image FROM driversnew WHERE id = {$_GET['drivers']}"; $result = mysql_query($sql) or die('Delete photo failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); define("GALLERY_IMG_DIR", "./images/"); // remove the image and the thumbnail from the server unlink(GALLERY_IMG_DIR . $row['image']); unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['image']); // and then remove the database entry } } /////////// this where the upload script starts/////////// this where the upload script starts//////// this where the upload script starts //define a maxim size for the uploaded images define ("MAX_SIZE","100"); // define the width and height for the thumbnail // note that theese dimmensions are considered the maximum dimmension and are not fixed, // because we have to keep the image ratio intact or it will be deformed define ("WIDTH","150"); define ("HEIGHT","100"); // this is the function that will create the thumbnail image from the uploaded image // the resize will be done considering the width and height defined, but without deforming the image function make_thumb($img_name,$filename,$new_w,$new_h) { //get image extension. $ext=getExtension($img_name); //creates the new image using the appropriate function from gd library if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext)) $src_img=imagecreatefrompng($img_name); //gets the dimmensions of the image $old_x=imageSX($src_img); $old_y=imageSY($src_img); // next we will calculate the new dimmensions for the thumbnail image // the next steps will be taken: // 1. calculate the ratio by dividing the old dimmensions with the new ones // 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable // and the height will be calculated so the image ratio will not change // 3. otherwise we will use the height ratio for the image // as a result, only one of the dimmensions will be from the fixed ones $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } // we create a new image with the new dimmensions $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); // resize the big image to the new created one imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); // output the created image to the file. Now we will have the thumbnail into the file named by $filename if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); //destroys source and destination images. imagedestroy($dst_img); imagedestroy($src_img); } // This function reads the extension of the file. // It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. If the error occures the file will not be uploaded. $errors=0; // checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a known extension, we will suppose it is an error, print an error message //and will not upload the file, otherwise we continue if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { // get the size of the image in bytes // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which the uploaded file was stored on the server $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); //we verify if the image has been uploaded, and print error instead if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name='images/thumbs/'.$image_name; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("eurico_edy", $con); $query = "UPDATE products SET name = '$name', location = '$location', date_of_birth='$date_of_birth', car_number='$car_number', favourite_track='$favourite_track', least_favourite_track='$least_favourite_track', achievements='$achievements', achievements='$achievements' email='$email', image='$image' WHERE id = '$id'"; echo "<h1>Thumbnail created Successfully!</h1>"; echo '<img src="'.$thumb_name.'">'; echo ''.$newname.''; mysql_close($con); } ?> Hi all, I have this: Code: [Select] <?php session_start(); include('login/functions.php'); $username = $_SESSION['username']; $check = mysql_query("SELECT email FROM user_profile WHERE username = '$username'"); $a = mysql_fetch_field($check); if(empty($a)) { header('Location: complete.php'); } ?> However if the field is empty, ie no email address for user then nothing happens? Am going about this the right way? Cheers I have a number of fields to display on a page, from a mysql query, some fields are empty, some not. depends on what they choose on the original form. I am trying to display on the form results on a page formatted using the below: If the mysql field is empty, display an unchecked check box next to the result. If there is data in the field display a check box ticked. What can i do to achieve this, can you point me in the right direction? Results page using echo: </TD><TD>Options: <input type='checkbox' CHECKED>". $row[17]. " </TD> = is not empty field </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[17]. " </TD> = emtpy ,mysql field </TD><TD>Options: <input type='checkbox' CHECKED>". $row[18]. " </TD> = not empty mysql field from query </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[18]. " </TD> = Empty field in mysql I am trying to show Rows 1 to 16 to display normally, rows 17 to 30 use the above logic. There are about 30 fields to display like this, the others are required fields and are displayed no matter what. Hello everebody, i have code to updare many rows at once using "for". when i click submit button nothing happens, where is the error in my code? thank you very much for your help <?php $hoster="db.mkq.de"; $username="dbxxxxxx"; $password="xxxxxx"; $db_name="xxxxxx"; mysql_connect("$hoster", "$username", "$password") or die("cannot connect"); mysql_select_db("$db_name") or die("cannot select DB"); $sql="SELECT * FROM gbook"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>www</strong></td> <td align="center"><strong>email</strong></td> <td align="center"><strong>pwd</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"> <input name="id[]" type="text" id="id" value="<? echo $rows['id']; ?>"> </td> <td align="center"> <input name="www[]" type="text" id="www" value="<? echo $rows['www']; ?>"> </td> <td align="center"> <input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>"> </td> <td align="center"> <input name="pwd[]" type="text" id="pwd" value="<? echo $rows['pwd']; ?>"> </td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="submit" id="submit" value="update"></td> </tr> </table> </td> </tr> </form> </table> <?php if($submit) { for($i=0;$i<$count;$i++) { $sql1="UPDATE gbook SET www='$www[$i]', email='$email[$i]', pwd='$pwd[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1) { header("location:editmulti3.php"); } mysql_close(); ?> Ok so i have registration page on my webs but i didn't work on empty fields so how could i check all fields? Code: [Select] //if no name if(!$name){ $error = "Username missing."; } //if no pass if($pass == false){ $error = "$error,Password missing"; } //if no pass conf if($pass_conf == false) { $error = "$error,Pass conf missing."; } //if no email if($email == false){ $error = "$error,Email missing."; } //pass conf if($pass != $pass_conf){ $error = "$error,Passwords do not match."; } echo "<script>alert('$error');</script>;"; //header("Location: register.php"); My script gives same results every time (even if i fill any of fields)...also if i un-comment header command it wont show alert..it just reloads the page So can anyone help me with this? Thanks.. Hi people I need a way to loop through an array where $imgid is some random number assigned to each array element and there are 4 fields id, url, tnurl, caption per array element. I need to extract these 4 fields in the same loop iteration. Thanks Code: [Select] $_SESSION['imagegallery'][$imgid]['id']; $_SESSION['imagegallery'][$imgid]['url']; $_SESSION['imagegallery'][$imgid]['tnurl']; $_SESSION['imagegallery'][$imgid]['caption']; example: Code: [Select] $_SESSION['imagegallery'][347]['id']; $_SESSION['imagegallery'][347]['url']; $_SESSION['imagegallery'][347]['tnurl']; $_SESSION['imagegallery'][347]['caption']; $_SESSION['imagegallery'][892]['id']; $_SESSION['imagegallery'][892]['url']; $_SESSION['imagegallery'][892]['tnurl']; $_SESSION['imagegallery'][892]['caption']; Hi all, I have a data base with the following table: ---member_data--- id ^ mid ^fieldname^ fieldvalue 1 - 2 - applicant - Seth Smith 2 - 4 - firstname - Chris 3 - 4 - lastname - Cooper 4 - 7 - full_name - Joey Jones 5 - 7 - occupation - Programmer 6 - 7 - phone - 800-555-1212 And below is a snippet that I use to display the selected members data for editing ------------------------------- <table> <tr> <td>Name:</td> <td>Value:</td> </tr> <?php $query = "SELECT * FROM member_data WHERE mid='$mid'"; $result= mysql_query($query); while($row = mysql_fetch_array($result)) { $fieldname = $row["fieldname"]; $fieldvalue = $row["fieldvalue"]; ?> <tr> <td><input type="text" name="<?php echo $fieldname;?>" value="<?php echo $fieldname;?>"></td> <td><input type="text" name="<?php echo $fieldvalue;?>" value="<?php echo $fieldvalue;?>"></td> <?php } ?> </tr> </table> ------------------------------- My question is: - using the Db example above: - lets say Ive selected mid#7 (member id 7) to edit which is displayed using the snippet code from above. - once displayed how do I edit mid#7 given the fact that mid#7 is located on 3 seperate rows from the same table? Thank you, Dave *ALSO - I tried the snippet below which did Not work. foreach($_POST as $key => $val) { $sql = "UPDATE member_data SET fieldname='$key', fieldvalue='$val' WHERE mid='$mid'"; $result = mysql_query($sql); } i have a form per row with an update button my problem is to update each row at a time so i created a unique update button per row, not working Code: [Select] <table cellspacing="0" cellpadding="0" border="1"> <col width="75" span="5" /> <tr> <td width="75">Proposal</td> <td width="75"> </td> <td width="75">Supplier</td> <td width="75">Downpayment</td> <td width="75">Payment Method</td> <td width="75">Status</td> <td width="75"> </td> </tr> <?php do { ?> <tr><form id="form1" name="form1" method="post" action=""> <td><?php echo $row_RsDownPayment['RequestID']; ?>-<?php echo $row_RsDownPayment['ProposalID']; ?></td> <td><?php echo $row_RsDownPayment['CustomerLastName']; ?></td> <td><?php echo $row_RsSupplier['SupplierName']; ?></td> <td><?php echo $row_RsDownPayment['PREPAYMENT2SUPPLIER']; ?></td> <td><select name="PaymentMethod" id="PaymentMethod"> <option value="0">Choose</option> <option value="Bank Transfer">Bank Transfer</option> <option value="CreditCard">CreditCard</option> <option value="Cash">Cash</option> <option value="PayPal">PayPal</option> </select></td> <td><?php echo $row_RsStatus['StatusLabel']; ?></td> <td><input name="<?php echo $U='Update'.$row_RsDownPayment['ProposalID'];?>" type="submit" value="Update" /> </td></form> </tr> <?php $con = mysql_connect("host","db","db"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("db", $con); if (isset($_POST['Update121'])) { $query=mysql_query("UPDATE proposals SET StatusID='$_POST[StatusID]' WHERE ProposalID = '$row_RsDownPayment[ProposalID]'"); exit; } ?> <?php } while ($row_RsDownPayment = mysql_fetch_assoc($RsDownPayment)); ?> </table> Can anyone tell me the best way to handle empty search field on a mysql Query? The query below if $name is left blank but the other fields are filled it shows no results, currently i use if.... else.... but that means i have a lot of code replicated, is there a better way? $sql = "SELECT private.username, se.age, se.ro, se.suc, se.bu, se.fu, com.in, com.ol, se.di, se.bo, se.uin FROM Reg_Profile_public AS se INNER JOIN Reg_Profile_Private AS private USING (uin) INNER JOIN Reg_Profile_public_Com AS com USING (uin) WHERE se.age BETWEEN '$low' AND '$high' AND se.ro=''$name"; I see some of the fields in mysql show NULL and some are just empty, wonder what is the difference, is empty field still NULL? Hi there, hope have some help. I have a form where a user select time and days of the week (monday, tuesday..) that he is available. The insert script works fine, it insert and the days of week he checked in the table, the only problme is when i try to update each of them.
I used this code above, but is not working, instead of updating/inserting days that is selected is inserting multi-records with the same day of the week value.
here it is:
foreach($weekDay as $DaysofWeek){ $sql_days = "UPDATE available SET day_time = '$day_time', week_day = '$DaysofWeek' WHERE user_id = '$id_user'"; $update_availability = mysql_query($sql_days); } Having a bit of a problem with the code below, I am trying to get it the print the html code if the MySql field is not empty but its not working. Any ideas guy? thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $uincookie = $_COOKIE["uin"]; require("./include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = mysql_query("SELECT * FROM Reg_Profile_images WHERE uin ='$uincookie'"); $i=1; while($rows = mysql_fetch_array($result)){ if (isset($row[image_zero])) { print "<p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form3\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button3\" id=\"button3\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form4\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button3\" id=\"button4\" value=\"Make Primary\" /> </div> </label> </form></td> </tr> </table></td>\n"; } if (isset($row[image_one])) { print "<td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form5\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button4\" id=\"button5\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form6\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button4\" id=\"button6\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_two])) { print " </tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form7\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button5\" id=\"button7\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form8\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button5\" id=\"button8\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_three])) { print " </tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form9\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button6\" id=\"button9\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form10\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button6\" id=\"button10\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_four])) { print " </tr> </table></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form2\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button2\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_five])) { print " </tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form11\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button11\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form12\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button12\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_six])) { print "</tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form13\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button13\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form14\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button14\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_seven])) { print " </tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form15\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button15\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form16\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button\" id=\"button16\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_eight])) { print " </tr> </table></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form17\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button17\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form18\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button18\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_nine])) { print "</tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form19\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button19\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form20\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button20\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_ten])) { print "</tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form21\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button21\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form22\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button22\" value=\"Make Primary\" /> </div> </label> </form></td>\n"; } if (isset($row[image_eleven])) { print "</tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form23\" name=\"form1\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button23\" value=\"Delete Picture\" /> </div> </label> </form></td> </tr> <tr> <td><form id=\"form24\" name=\"form2\" method=\"post\" action=\"\"> <label> <div align=\"center\"> <input type=\"submit\" name=\"button2\" id=\"button24\" value=\"Make Primary\" /> </div> </label> </form></td> </tr> </table></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>\n"; } //if($i %4 == 0) { echo '</tr><tr>'; } // this will create the line separator by inserting a row when the $i is dividable by 4 } ?> </table> <p> </p> <p> </p> </body> </html> Now this one is a bit of a shit head. I am using a really comprehensive class i found on on the web for upload / re-size / crop but i want to be able to override it's error handling and i am not good enough to start modifying the code in the class with out fucking it up. Firstly i will show you how i have invoked the class. Code: [Select] if( isset($_FILES['image'] ) ) { //Class includes include("../scrips/php/cms/database.insert.class.php"); include ("../scrips/php/cms/img.upload.resize.crop.class.php.php"); //----------|Start: upload, resize & save $your_image = new _image; //----------| Upload orginal image $your_image->uploadTo = 'uploads/'; $upload = $your_image->upload($_FILES['image']); //----------| Resize and upload small thumbnail $your_image->newPath = 'thums/'; $your_image->newWidth = 50; $your_image->newHeight = 50; $resized = $your_image->resize(); //----------| Resize and upload medium thumbnail $your_image->newPath = 'thums2/'; $your_image->newWidth = 100; $your_image->newHeight = 100; $resized = $your_image->resize(); //----------| Getting the image name to insert into the database futher on in the code $name = $resized; $img_str = explode("/",$name); $final_img_name = $img_str['1']; echo "Article has been added!"; //----------------|end //----------------| Start database insert (class manipulation) $table = "blog_posts"; $title = "'".$_POST['ArticleTitle']."',"; $img = "'".$final_img_name."',"; $post = "'".$_POST['ArticleBody']."',"; $aurthor_id = "'1',"; $category_id = "'".$_POST['Category']."',"; $date_posted = "NOW()"; $values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted"); $fields = array('title,','img,','post,','aurthor_id,','category_id,','date_posted'); $obj= new DatabaseInsert; $obj->DatabaseConnectionRequire(); $obj->ArticleInsert($values,$fields,$table); //----------------|end } As you can see it's fairly basic. What i want to do is before it runs this script and starts including/invoking the class etc, i want to be able to check to see if there is a value been posted from a FILE FORM OBJECT and if there is to proceed with this script, alternatively i want it to execute another code which will handle it in regards to the concept of my page. A simple javascript alert with be ok providing it reloaded the page to it's default state. If any one can help me here i would appreciate it a lot. Thanks |