alexmark Posted July 15, 2012 Share Posted July 15, 2012 Hi all Ok I have a form copy attached. the form works untill it reached the picture posting part. For some reason it will not post the image urls to teh db but it uploads teh images as it should to the correct folders. Any sujestions welcome. I have tried everything I can think of over the last 2 days and still no futher infront. <?php if ( $_SESSION['logged_in'] ): ?> (1) <?php endif; ?> <?php if(isset($_POST['formSubmit'])) { $errorMessage = ""; if(empty($_POST['formsocial'])) { $errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>"; } if(empty($_POST['formurl'])) { $errorMessage .= "<li>You forgot to enter a URL!</li>"; } $varsocial = $_POST['formsocial']; $varurl = $_POST['formurl']; if(empty($errorMessage)) { include 'dbc.php'; $sql = "INSERT INTO social (id, social, url) VALUES (". PrepSQL($id) . ", " . PrepSQL($varsocial) . ", " . PrepSQL($varurl) . ") " ; if(mysql_query($sql)){ $socialId = mysql_insert_id(); include 'imageresizer.class.php'; include 'upload_class.php'; $imagePath = 'socialloads/'.$social; $thumbPath = 'socialthumbnails/'.$social; for($i==0; $i<10; $i++){ if(!empty($_FILES['formImage'.$i]['tmp_name'])){ if(!is_dir($imagePath.'/')){ mkdir($imagePath.'/', 0777); } // Generate Thumbnails if(!is_dir($thumbPath.'/')){ mkdir($thumbPath.'/', 0777); } $UF_obj = new Upload(); $UF_obj -> File = $_FILES['formImage'.$i]; $UF_obj -> SavePath = $imagePath.'/'; // PLACE where you want to save images. $UF_obj -> ThumbPath = $thumbPath.'/'; //if not specify will not create thumbnil $UF_obj -> NewName = $_FILES['formImage'.$i]['name']; //width and height of large image which will save in "pictures/" folder $UF_obj -> NewWidth = 150; $UF_obj -> NewHeight = 150; ////width and height of thumb image which will save in "pictures/thumb/" folder $UF_obj -> TWidth = 30; $UF_obj -> THeight = 30; /* * if you want to name image something other then upload image name then use bellow formate * for example you upload two images then * * $UF_obj -> NewName = array('NewName1.jpg', 'NewName2.jpg'); */ $UF_obj -> NameCase = 'lower'; //default no change. upper for upper case $UF_obj -> OverWrite = true; //default = true. replace existing image //UploadFile() function upload and resize image. //function return error message if any. //error variable is in array form. so you can get more then one error/warning messages. // or you can also access error message by class object varialbe like $UF_obj -> Error $Error = $UF_obj -> UploadFile(); // INSERT images to DB if(empty($Error)){ $imageInsert = "INSERT INTO socialimages (imagepath, imagethumbpath, mainimage, socialid,)Values ('".$imagePath."/".$_FILES['formImage'.$i]['name']."','".$thumbPath."/".$_FILES['formImage'.$i]['name']."','0','".$socialid."','1')"; mysql_query($imageInsert); }else{ if(is_array($Error)){ foreach($Error as $key=>$val) { echo $val . '<br>'; } } } } } echo("<ul style='color:green;'>Your Listing is Successfully Listed!</ul>\n"); } } } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value) { // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Add social Media</title> <link href="/csssheet.css" rel="stylesheet" type="text/css"> </head> <body> <center><div style="width:785px"> <table td class="background1" valign="top" width="785px" colspan="1" border=0 cellpadding=0 cellspacing=0 align="center"> <tr> <td width="100%"><center><br><a href= "../admin.php" class="creamlink11">Log Out</a></center></td> </tr> <td></td> </table> <?php include("../menu/admin_menu.php") ?> </td> </tr> <tr> <td bgcolor="#F6F6F6" height='1'></td> </tr> <tr> <td > <table width="785" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="785" bgcolor="#232B34" class="bodyfontred"> <table border=0 width='100%' cellspacing=0 cellpadding=0> <tr> <td valign="top" align=center> </td> </tr> <tr> <td align=center> <center> <img src="/images/linebreak.jpg" width="350" height="1"> </center> <?php if(!empty($errorMessage)) { echo("<p>There was an error with your form:</p>\n"); echo("<ul>" . $errorMessage . "</ul>\n"); } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data"> <table> <tr> <td class="bodyfontwhite" align="right"> <label for='formsocial'>Social Media Name</label></td> <td><input type="text" name="formsocial" size="40" maxlength="100" value="<?=$varsocial;?>"/></td> <td><label for='formurl'>URL</label></td> <td><input type="text" name="formurl" size="40" maxlength="250" value="<?=$varurl;?>"/></td> </tr> <tr> <td align="right" label for='formImage1'>Add Image: </td> <td><input name="formImage1" type="file" id="formImage1" value="<?=$varImage1;?>"/></td> </tr> <tr> </tr> </table> <center><input type="submit" name="formSubmit" value="Submit"/></center> </form> <tr><td class=bodyfontwhite> <center><b><a name='help'></a>H E L P</b></center><br> <p align=justify>To Add a Social Net Work type the text you wish to display. Add the URL address Then click the Submit button. </p> </td></tr></table> </td> </tr> </table> </td> </tr> <tr> <center><td width="785" align="center" bgcolor="#000000" class="bodyfont" height="40"><a href="http://www.improvedinternetmarketing.com/" title="Improved Internet Marketing">Web Design</a> by Improved Internet Marketing</TD></center> </tr> </table> </div></center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/265725-form-submits-but-will-not-post-all-data-to-db/ Share on other sites More sharing options...
NomadicJosh Posted July 15, 2012 Share Posted July 15, 2012 Do you have this somewhere in your code? <?php $_POST['formImage1']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/265725-form-submits-but-will-not-post-all-data-to-db/#findComment-1361759 Share on other sites More sharing options...
alexmark Posted July 16, 2012 Author Share Posted July 16, 2012 Yes at the point where you select the file to upload. <tr> <td align="right"><div align="left"><strong>Upload Image:</strong></div></td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'> </td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'>Add Image: </td> <td><input name="formImage1" type="file" id="formImage1" value="<?=$varImage1;?>"/></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/265725-form-submits-but-will-not-post-all-data-to-db/#findComment-1361764 Share on other sites More sharing options...
alexmark Posted July 16, 2012 Author Share Posted July 16, 2012 Whoops. Sorry I miss understood you. No I have not got that in the code. I have the following to upload teh urls to the data base. if(empty($Error)){ $imageInsert = "INSERT INTO socialimages (imagepath, imagethumbpath, mainimage, socialid,)Values ('".$imagePath."/".$_FILES['formImage'.$i]['name']."','".$thumbPath."/".$_FILES['formImage'.$i]['name']."','0','".$socialid."')"; mysql_query($imageInsert); }else{ if(is_array($Error)){ foreach($Error as $key=>$val) Quote Link to comment https://forums.phpfreaks.com/topic/265725-form-submits-but-will-not-post-all-data-to-db/#findComment-1361765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.