justAnoob Posted May 12, 2009 Share Posted May 12, 2009 I get a progress bar moving,, then the page refreshes back to my form,, but no upload.. This use to work. <?php /////////////////////////////////////form page if(empty($row['imgpath2'])) { echo "<form action='postnewitem2.php' method='post' enctype='multipart/form-data' name='form22' id='form22'> <div align='center'> <input name='image' type='file' id='image' size='15' input='input' /> <br> <input name='submit' type='submit' value='Upload Picture 2' id='submit' /> </div> </form>"; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } ?> <?php session_start(); require 'connection.php'; mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); $item_name = mysql_real_escape_string($_POST['item_name']); $id = mysql_real_escape_string($_POST['id']); $category = mysql_real_escape_string($_POST['category']); define ("MAX_SIZE","1000"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['submit'])) { $image=$_FILES['image']['name']; if($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { echo '<h1>Picture is not in correct format.</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit on your picture.</h1>'; $errors=1; } $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>There was an error posting your pic. Please try again.</h1>'; $errors=1; } } } } $mysqlcategory = $category; $imgpath = $newname; $findit = $_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE username = '$findit'"); $row=mysql_fetch_assoc($result); $user_id = $row['id']; $sql = "INSERT INTO abcxyz(imgpath2)VALUES('$imgpath')WHERE id = '$id' and user_id = '$user_id'"; mysql_query($sql) or die(mysql_error()); if(isset($_POST['submit']) && !$errors) { echo "Complete"; unset($_SESSION['updatecomplete']); } ?> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 12, 2009 Author Share Posted May 12, 2009 Oh yeh,, by if statement is inside another form,,and both forms having different names. Quote Link to comment 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.