Jump to content

uploading multiple pix with a form


Panta
 Share

Recommended Posts

after uploading the pix and submiting the for i do get error massage saying" Notice: Undefined variable: filepath1 in C:\wamp\www\online_stoke\my\testing.php on line 53Notice: Undefined variable: filepath in C:\wamp\www\online_stoke\my\testing.php on line 53please can some one tell me where the problem is from these are my scripts<?php require('siteadmin.header.php'); include_once ("inc/auth.php"); include('checkadmin.php'); $auth= new auth();?> <!-- CSS --> <link rel="stylesheet" href="css/form.css" type="text/css" /> <!-- JavaScript --> <script type="text/javascript" src="scripts/wufoo.js"></script> <div id="container"> <div class="info"> <h2>Add New Item</h2> </div> <div> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><a href="adminindex.php"><img src="buttons/button1up.png" border="0" id="button1" vspace="1" hspace="1"></a><a href="items.php"><img src="buttons/button2up1.png" border="0" id="button2" vspace="1" hspace="1"></a><a href="purchase.php" ><img src="buttons/button3up1.png" border="0" id="button3" vspace="1" hspace="1"></a><a href="sales.php" ><img src="buttons/button4up1.png" border="0" id="button4" vspace="1" hspace="1"></a><a href="logout.php" ><img src="buttons/button5up1.png" border="0" id="button5" vspace="1" hspace="1"></a><br></td> </tr> </table> </div> <form id="form1" name="form1" class="wufoo " enctype="multipart/form-data" autocomplete="on"method="post" ><?php if (isset($_POST['_submit_check'])){ $name = $_POST["name"]; $info = $_POST["info"]; $sn = $_POST["sn"]; $categorie = $_POST["categorie"]; $whouse =$_POST["whouse"]; $package = $_POST["packid"]; $cost = $_POST["cost"]; $auth->connect(); if($sn == 0){ ?> <div align="center" style="border:2px solid red"> <b>enter serial number</b> </div><?php } else { $result = $auth->displaystock($sn,'sn'); $row = mysql_num_rows($result); if($row > 0){?> <div align="center" style="border:2px solid red"> <b>Item already defined</b> </div> <?php } else{ $query = "INSERT INTO stock (name,info,sn,categorie,package,cost,whouse , pix, otherpix) VALUES ('$name', '$info ', '$sn', '$categorie','$package', '$cost','$whouse' ,'$filepath', '$$filepath1')";?> <div align="center" style="border:2px solid red"> <b>item inserted</b> </div> <?php print " \n\n\n"; } } }?> <div class="info"> <h4><a href="reportstock.php">Go To Report</a></h4> </div> <ul> <li><?phpecho ' <input type="file" name="file[]" size="30" style="cursor:hand;"/> <br /> ';echo ' <input type="file" name="file[]" size="30" style="cursor:hand;"/> <br /> ';echo '<input type="submit" name="action" value="Upload" />'; if(isset($_POST['action'])) { $uploaddir = "../my/images/stockpix/"; $filename = $_FILES['file']['name'][0]; $filename1 = $_FILES['file']['name'][1]; $filetmp = $_FILES['file']['tmp_name'][0]; $filetmp1 = $_FILES['file']['tmp_name'][1]; $filesize = $_FILES['file']['size'][0]; $filesize1 = $_FILES['file']['size'][1]; $filetype = $_FILES['file']['type'][0]; $filetype1 = $_FILES['file']['type'][1]; $ext = substr(strrchr($filename, "."),1); $ext1 = substr(strrchr($filename1, "."),1); $conf = $uploaddir . $filename; $conf1 = $uploaddir . $filename1; $filepath = $uploaddir . $filename; $filepath1 = $uploaddir . $filename1; if ($filename != "" && $filename1 != "") { if (!file_exists($filepath) && !file_exists($filepath1)) { if ($ext == "jpg" || $ext == "gif" || $ext == "tiff" || $ext == "png" || $ext == "bmp" && $ext1 == "jpg" || $ext1 == "gif" || $ext1 == "tiff" || $ext1 == "png" || $ext1 == "bmp") { if($filesize < "500000" && $filesize1 < "500000") { $upload = move_uploaded_file($filetmp, $filepath); $upload1 = move_uploaded_file($filetmp1, $filepath1); echo '<font color=blue>'. $filename . ' and '. $filename1 . ' <i>was successfully uploaded...</font><br />'; } else { echo '<font color=red>'.$filename . ' or '. $filename1 . ' <i>greater than the maximum file size allowed...</font><br />'; } } else { echo '<font color=red>'. $filename . ' or '. $filename1 . ' <i>is invalid file type...</font><br />'; } } else { echo $filename . ' or '. $filename1 . ' <i>already exists...</i><br />'; } } ?> <img src = "<?php echo $filepath;?>" width="200" height="300"> <img src = "<?php echo $filepath1;?>" width="200" height="300"><?php } else { $filepath="none"; $filepath1="none"; ?> <?php }?><input type="text" readonly="" name="fileName" value="<?php if(isset($_POST['action'])) {echo $filepath;} else echo "";?>" /> <input type="text" readonly="" name="fileNamea" value="<?php if(isset($_POST['action'])) {echo $filepath1;} else echo '';?>" /> </li> <li id="foli1" > <label class="desc" > Item </label> <div> <input name="name" type="text" class="field text medium" maxlength="255" tabindex="1"/> </div> </li> <li id="foli1" > <label class="desc"> SN </label> <div> <input name="sn" type="text" class="field text medium" value="" maxlength="255" tabindex="2" /> </div> </li> <li id="foli3" > <label class="desc" > Description </label> <div> <textarea name="info" class="field textarea small" rows="10" cols="50" tabindex="3"></textarea> </div> </li> <li id="foli0" > <label class="desc"> Appraised Value </label> <span class="symbol">$</span> <span> <input name="cost" type="text" class="field text currency" size="10" tabindex="4" /> <label for="Field0">Dollars</label> </span> </li> <li id="foli6" > <label class="desc" for="Field6"> ware house </label> <div> <input name="whouse" type="text" class="field text medium" maxlength="255" tabindex="5" /> </div> </li> <li id="foli7" > <label class="desc"> Categorie </label> <div> <select name="categorie" class="field select medium" tabindex="6" > <option value="1" > Mercedes </option> <option value="2" > Mazda </option> <option value="3" > Toyota </option> <option value="4" > Camry </option> <option value="5" > Nissian </option> <option value="6" > Others </option> </select> </div> </li> <li id="foli9"> <label class="desc" > package? </label> <div class="col"> <input name="packid" type="hidden" value="" /> <input name="packid" type="radio" class="field radio" value="1" tabindex="7" /> <label class="choice" for="Field9_0" > unit </label> <input name="packid" type="radio" class="field radio" value="2" tabindex="8" /> <label class="choice" for="Field9_1" > box </label> <input name="packid" type="radio" class="field radio" value="3" tabindex="9" /> <label class="choice" for="Field9_1" > Kg </label> </div> </li> <li class="buttons"> <input id="saveForm" class="btTxt submit" type="submit" name="add" value="Submit" tabindex="10" /> <input type="hidden" name="_submit_check" value="1"/> </li> <li style="display:none"> <label for="comment">Do Not Fill This Out</label> <textarea name="comment" id="comment" rows="1" cols="1"></textarea> </li> </ul> </form> </div><!--container--><?php require('siteadmin.footer.php');?>

Link to comment
Share on other sites

I think it has something to do with this line:

$query = "INSERT INTO stock (name,info,sn,categorie,package,cost,whouse , pix, otherpix) VALUES ('$name', '$info ', '$sn', '$categorie','$package', '$cost','$whouse' ,'$filepath', '$$filepath1')";

specifically this part:

,'$filepath', '$$filepath1'

I didn't see $filepath being created unless it is in those include files at the top, $$filepath1 just looks like trouble

Edited by astralaaron
Link to comment
Share on other sites

this is my correction but i still ve problems

<?php    	require('siteadmin.header.php');	include_once ("inc/auth.php");	include('checkadmin.php');	$auth= new auth();?>		<!-- CSS -->	<link rel="stylesheet" href="css/form.css" type="text/css" />		<!-- JavaScript -->	<script type="text/javascript" src="scripts/wufoo.js"></script>	<div id="container">		<div class="info">			<h2>Add New Item</h2>		</div>		<div>			<table border="0" cellpadding="0" cellspacing="0">				<tr>					<td><a href="adminindex.php"><img src="buttons/button1up.png" border="0" id="button1" vspace="1" hspace="1"></a><a href="items.php"><img src="buttons/button2up1.png" border="0" id="button2" vspace="1" hspace="1"></a><a href="purchase.php" ><img src="buttons/button3up1.png" border="0" id="button3" vspace="1" hspace="1"></a><a href="sales.php" ><img src="buttons/button4up1.png" border="0" id="button4" vspace="1" hspace="1"></a><a href="logout.php" ><img src="buttons/button5up1.png" border="0" id="button5" vspace="1" hspace="1"></a><br></td>				</tr>			</table>		</div>		<form id="form1" name="form1" class="wufoo " enctype="multipart/form-data" autocomplete="on"method="post" ><?php	if (isset($_POST['_submit_check'])){		$name = $_POST["name"];		$info = $_POST["info"];		$sn = $_POST["sn"];		$categorie = $_POST["categorie"];		$whouse =$_POST["whouse"];		$package = $_POST["packid"];		$cost = $_POST["cost"];		$insert= $_POST["fileName"];		$insert1= $_POST["fileNamea"];		 		$auth->connect();		if($sn == 0){		  ?>			<div align="center" style="border:2px solid red">				<b>enter serial number</b>			</div><?php		}		else {			$result = $auth->displaystock($sn,'sn');			$row = mysql_num_rows($result);			if($row > 0){?>			<div align="center" style="border:2px solid red">				<b>Item already defined</b>			</div>		<?php			}			else{				$query = "INSERT INTO stock (name,info,sn,categorie,package,cost,whouse ,  pix,  otherpix) VALUES ('$name', '$info ', '$sn', '$categorie','$package', '$cost','$whouse' ,'$insert', '$insert1')";?>			<div align="center" style="border:2px solid red">				<b>item inserted</b>			</div>	<?php				print "	\n\n\n";			} 		}	}?>			<div class="info">				<h4><a href="reportstock.php">Go To Report</a></h4>			</div>			<ul>				<li><?phpecho ' <input type="file" name="file[]" size="30" style="cursor:hand;"/> <br /> ';echo ' <input type="file" name="file[]" size="30" style="cursor:hand;"/> <br /> ';echo '<input type="submit" name="action" value="Upload" />'; 	if(isset($_POST['action']))	{	   	 $uploaddir = "../my/images/stockpix/";					$filename = $_FILES['file']['name'][0];			$filename1 = $_FILES['file']['name'][1];			$filetmp  = $_FILES['file']['tmp_name'][0];			$filetmp1 = $_FILES['file']['tmp_name'][1];			$filesize = $_FILES['file']['size'][0];			$filesize1 = $_FILES['file']['size'][1];			$filetype = $_FILES['file']['type'][0];			$filetype1 = $_FILES['file']['type'][1];			$ext = substr(strrchr($filename, "."),1);			$ext1 = substr(strrchr($filename1, "."),1);			$conf = $uploaddir . $filename;			$conf1 = $uploaddir . $filename1;			$filepath = $uploaddir . $filename;			$filepath1 = $uploaddir . $filename1;		if ($filename != "" && $filename1 != "")		{					if (!file_exists($filepath) && !file_exists($filepath1))			{				if ($ext == "jpg" || $ext == "gif" || $ext == "tiff" || $ext == "png" || $ext == "bmp" && $ext1 == "jpg" || $ext1 == "gif" || $ext1 == "tiff" || $ext1 == "png" || $ext1 == "bmp")				{					if($filesize < "500000"  && $filesize1 < "500000")					{						$upload = move_uploaded_file($filetmp, $filepath);						$upload1 = move_uploaded_file($filetmp1, $filepath1);						echo '<font color=blue>'. $filename . '   and	'. $filename1 . ' <i>was successfully uploaded...</font><br />';						}					else					{						echo '<font color=red>'.$filename . '   or	'. $filename1 . ' <i>greater than the maximum file size allowed...</font><br />';					}				}				else				{					echo '<font color=red>'. $filename . '   or	'. $filename1 . ' <i>is invalid file type...</font><br />';				}				}			else			{				echo $filename . '   or	'. $filename1 . ' <i>already exists...</i><br />';			}		} ?>					<img src = "<?php echo $filepath;?>" width="200" height="300">					<img src = "<?php echo $filepath1;?>" width="200" height="300"><?php	}	else {	 $filepath="none";		 $filepath1="none";	?>												<?php	}?><input type="text" readonly="" name="fileName" value="<?php if(isset($_POST['action']))	 {echo $filepath;} else echo "";?>" />	 <input type="text" readonly=""  name="fileNamea" value="<?php if(isset($_POST['action']))	 {echo $filepath1;} else echo '';?>" />				</li>				<li id="foli1"	 >					<label class="desc" >						Item					</label>					<div>						<input name="name" type="text" class="field text medium"	 maxlength="255" tabindex="1"/>					</div>				</li>					<li id="foli1" >					<label class="desc">						SN					</label>					<div>						<input  name="sn" type="text" class="field text medium" value="" maxlength="255" tabindex="2" />					</div>				</li>				<li id="foli3" >					<label class="desc" >						Description					</label>					<div>						<textarea  name="info" class="field textarea small" rows="10" cols="50"	tabindex="3"></textarea>					</div>				</li>				<li id="foli0" >					<label class="desc">						Appraised Value					</label>					<span class="symbol">$</span>					<span>						<input	 name="cost" type="text" class="field text currency" size="10" tabindex="4" />							<label for="Field0">Dollars</label>					</span>									</li>				<li id="foli6" >					<label class="desc"  for="Field6">						ware house					</label>					<div>						<input	 name="whouse" type="text" class="field text medium" maxlength="255"	 tabindex="5" />					</div>				</li>				<li id="foli7" >					<label class="desc">						Categorie					</label>					<div>						<select name="categorie"		 class="field select medium"		 tabindex="6" >													<option value="1" >								Mercedes							</option>							<option value="2" >								Mazda							</option>							<option value="3" >								Toyota							</option>							<option value="4" >								Camry							</option>							<option value="5" >								Nissian									</option>							<option value="6" >								Others							</option>													</select>					</div>				</li>				<li id="foli9">					<label class="desc" >						package?					</label>					<div class="col">						<input  name="packid" type="hidden" value="" />										<input	 name="packid" type="radio" class="field radio" value="1" tabindex="7" />						<label class="choice" for="Field9_0" >							unit						</label>											<input name="packid" type="radio" class="field radio" value="2" tabindex="8" />						<label class="choice" for="Field9_1" >							box						</label>											<input name="packid" type="radio" class="field radio" value="3" tabindex="9" />						<label class="choice" for="Field9_1" >							Kg						</label>																	</div>				</li>				<li class="buttons">					<input id="saveForm" class="btTxt submit"  type="submit"  name="add" value="Submit" tabindex="10" />					<input type="hidden" name="_submit_check" value="1"/>				</li>				<li style="display:none">					<label for="comment">Do Not Fill This Out</label>					<textarea name="comment" id="comment" rows="1" cols="1"></textarea>				</li>			</ul>						</form>	</div><!--container--><?php		require('siteadmin.footer.php');?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...