Jump to content

Recommended Posts

Hey, me and my users have noticed that my upload store image has stopped working, when the click browser and choose it, the picture or whatever dont stay in the box next to the "browse" thing... any help would be much appreciated thanks! ???

 

<?php
include("header.php");
include("members.php");

$a = $_GET['action'];

if($a == '') {
$check = mysql_num_rows(mysql_query("SELECT * FROM `stores` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""));

if($check == 0) {
 	mysql_query("INSERT INTO `stores` (`user`, `site`) VALUES('{$_COOKIE['ELv2']}', \"$Z\")");
}

print "<h2>My Store</h2><p>";

print "<a href='http://www.eaglelegend.com/mystore.php?action=additem'>Add Item to My Store</a><p>";
print "<a href='http://www.eaglelegend.com/mystore.php?action=inventory'>View Inventory</a><p>";
print "<a href='http://www.eaglelegend.com/mystore.php?action=ad'>Post Advertisement!</a><p>";

$sql = mysql_query("SELECT * FROM `stores` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
while($row = mysql_fetch_array($sql)) {
 	extract($row);

	print "<form action='http://www.eaglelegend.com/mystore.php?action=update' method='post' enctype='multipart/form-data'>
	<input type='hidden' name='MAX_FILE_SIZE' value='512000'>
	Store Name<br>
	<input type='text' name='store_name' value=\"$store_name\" size='40' class='text_box' alt='$store_name' title='$store_name'><p>
	Store Open<br>
	<select name='open' size='1' class='text_box'>";

	if($open == 1) {
	 	print "<option value='1'>Open</option>
		 <option value='0'>Closed</option>";
	}
	else {
	 	print "<option value='0'>Closed</option>
		 <option value='1'>Open</option>";
	}

	print "</select><p>";

	if($store_image) {
	 	print "Store Image<br>
		 <img src='http://images.eaglelegend.com/storeimages/$store_image' class='text_box' alt='Store image' title='Store image'><p>";
	}

	print "Upload Store Image<br>
	<input type='file' name='image[]' size='50' class='text_box' alt='Upload store image' title='Upload store image'><p>
	<input type='submit' value=' Update Store ' class='text_box' alt='Confirm store changes' title='Confirm store changes'></form>";	 
} 
}
else {
	if($a == 'ad') {
	 	print "<h2>Post Advertisement</h2><p>";

	 	print "You can post an advertisement on the User Stores page. By doing so you will draw attention to your
	 	store! Advertisements cost $1 for every word in your advertisement!";

	 	print "<p><form action='http://www.eaglelegend.com/mystore.php?action=_ad' method='post'>
	 	Advertisement<br>
	 	<textarea rows=3 cols=40 nowrap name='post' class='text_box' alt='Enter your advertisement!' title='Enter your advertisement!'></textarea><p>
	 	<input type='submit' value=' Submit Ad ' class='text_box' alt='Submit your ad!' title='Submit your ad!'></form>";
	}

	if($a == '_ad') {
		$post = $_POST['post'];

	$words = count(explode(" ",$post));

	$cost = $words;

	if($cost > $POINTS) {
	 	print "<h2>Error</h2><p>
	 	You do not have enough gold to purchase this ad!<p>
		<a href='http://www.eaglelegend.com/mystore.php'>Click here to go back to My Store</a>";
	}
	else {
		$date = date("m/d/y");

		$user = $_COOKIE['ELv2'];

		$insert = mysql_query("INSERT INTO `ads` (`user`, `date`, `ad`, `site`) VALUES(\"$user\", '$date', \"$post\", \"$Z\")"); 

		$newdollar = $POINTS - $cost;

		$update = mysql_query("UPDATE `members` SET `points`='$newdollar' WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");

		if($insert && $update) {
		 	print "<h2>Ad Inserted!</h2><p>
		 	Your ad has been added to the User Shops page!<p>
		 	<a href='http://www.eaglelegend.com/userstores.php'>Click here to see it</a>";
		}
		else {
		 	print mysql_error();
		}
	}
	}

	if($a == 'delete') {
	 	$id = $_GET['id'];
	 	$food = $_GET['food'];

	 	if($food == 1) {	
 	 	$del = mysql_query("DELETE FROM `store_food` WHERE `id`='$id' AND `site`=\"$Z\"");
 	}
 	else {
 		$del = mysql_query("DELETE FROM `store_items` WHERE `id`='$id' AND `site`=\"$Z\"");
 	}

 	if($del) {
 	 	Header("Location: http://www.eaglelegend.com/mystore.php?action=inventory");
 	}
 	else {
 	 	print mysql_error();
 	}
}

if($a == 'inventory') {
	print "<h2>Manage Items</h2><p>";

	print "<a href='http://www.eaglelegend.com/mystore.php'>Back to My Store</a><P>";

	print "<a href='http://www.eaglelegend.com/mystore.php?action=additem'>Click here to add a new Item</a><p>";

	print "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000 width=100%>
	 <tr>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what the item looks like!' title='This shows what the item looks like!'><b>Image</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what the item is called!' title='This shows what the item is called!'><b>Item Name</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what type of item the item is!' title='This shows what type of item the item is!'><b>Item Type</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows how much the item costs!' title='This shows how much the item costs!'><b>Cost</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows how much gold the item is worth!' title='This shows how much gold the item is worth!'><b>Gold</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='If it is a weapon it shows how much damage (approx.) it can cause!' title='If it is a weapon it shows how much damage (approx) it can cause!'><b>Damage</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='Shows what actions you can make with this item!' title'Shows what actions you can make with this item!'><b>Actions</b></td>
	 </tr>";

	$sql = mysql_query("SELECT * FROM `store_items` WHERE `store_user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\" ORDER BY `name` ASC");
	while($row = mysql_fetch_array($sql)) {
		extract($row);

		if($type == "") {
		 	$type = "Regular Item";
		}
		else {
		 	$type = "Weapon";
		}

		print "<tr>
		 <td bgcolor=#ffffff class=other><a href='http://images.eaglelegend.com/items/$item.png'>
		 <img src='http://images.eaglelegend.com/items/$item.png' width='40' height='40' border='0'></a></td>
		 <td bgcolor=#ffffff class=other>$name</td>
		 <td bgcolor=#ffffff class=other>$type</td>
		 <td bgcolor=#ffffff class=other>$cost</td>
		 <td bgcolor=#ffffff class=other>$points</td>
		 <td bgcolor=#ffffff class=other>$damage</td>
		 <td bgcolor=#ffffff class=other><a href='http://www.eaglelegend.com/mystore.php?action=delete&id=$id'>Delete</a></td>
		</tr>"; 
	} 

	$sql = mysql_query("SELECT * FROM `store_food` WHERE `store_user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\" ORDER BY `name` ASC");
	while($row = mysql_fetch_array($sql)) {
		extract($row);

		$type = "Food";

		print "<tr>
		 <td bgcolor=#ffffff class=other><a href='http://images.eaglelegend.com/food/$item.png'>
		 <img src='http://images.eaglelegend.com/food/$item.png' width='40' height='40' border='0'></a></td>
		 <td bgcolor=#ffffff class=other>$name</td>
		 <td bgcolor=#ffffff class=other>$type</td>
		 <td bgcolor=#ffffff class=other>$cost</td>
		 <td bgcolor=#ffffff class=other>$points</td>
		 <td bgcolor=#ffffff class=other>$damage</td>
		 <td bgcolor=#ffffff class=other><a href='http://www.eaglelegend.com/mystore.php?action=delete&id=$id&food=1'>Delete</a></td>
		</tr>"; 
	} 			 

	print "</table>";

}

	if($a == 'additem') {
	 	print "<h2>Add Item to Store</h2><p>";
		print "You can only add items to your store if you have bought them from the main store!<p>
	<table border=0 cellpadding=3 cellspacing=1 width=100% bgcolor=#000000>
	 <tr>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what the item looks like!' title='This shows what the item looks like!'><b>Image</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what the item is called!' title='This shows what the item is called!'><b>Item Name</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows what type of item the item is!' title='This shows what type of item the item is!'><b>Item Type</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows how much the item costs!' title='This shows how much the item costs!'><b>Cost</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='This shows how much gold the item is worth!' title='This shows how much gold the item is worth!'><b>Gold</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='If it is a weapon it shows how much damage (approx.) it can cause!' title='If it is a weapon it shows how much damage (approx) it can cause!'><b>Damage</b></td>
	  <td bgcolor=#dddddd class='text_box' alt='Shows what actions you can make with this item!' title'Shows what actions you can make with this item!'><b>Actions</b></td>
	 </tr>"; 	 

		$sql = mysql_query("SELECT * FROM `items` WHERE `equipped`='0' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
		while($row = mysql_fetch_array($sql)) {
		 	extract($row);

			if($type == 'weapon') {
			 	$t = "Weapon";
			}
			else {
			 	$t = "Normal Item";
			}

			$sql1 = mysql_query("SELECT * FROM `available_items` WHERE `item`=\"$item\"");
			while($row1 = mysql_fetch_array($sql1)) {
			 	$cost = $row1["cost"];
			}

	 	print "<tr>
		  <td bgcolor=#ffffff class=other><img src='http://images.eaglelegend.com/items/$item.png' width='40' height='40'></td>
		  <td bgcolor=#ffffff class=other>$name</td>
		  <td bgcolor=#ffffff class=other>$t</td> 
		  <td bgcolor=#ffffff class=other><form action='http://www.eaglelegend.com/mystore.php?action=_additem&id=$id' method='post'>
		  <input type='text' name='cost' value='$cost' size='5' class='text_box' alt='Cost' title='Cost'></td>
		  <td bgcolor=#ffffff class=other>$points</td>
		  <td bgcolor=#ffffff class=other>$damage</td>
		  <td bgcolor=#ffffff class=other>
<INPUT TYPE=\"submit\" class=\"text_box\"
VALUE=\"Add to Inventory\"
onClick=\"this.disabled=true;return true;\">
</FORM>			  
		  </td>
		 </tr>";	
		}

		$sql = mysql_query("SELECT * FROM `fooditems` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
		while($row = mysql_fetch_array($sql)) {
		 	extract($row);

			$t = "Food";

			$sql1 = mysql_query("SELECT * FROM `available_food` WHERE `item`=\"$item\" AND `site`=\"$Z\"");
			while($row1 = mysql_fetch_array($sql1)) {
			 	$cost = $row1["cost"];
			}

	 	print "<tr>
		  <td bgcolor=#ffffff class=other><img src='http://images.eaglelegend.com/food/$item.png' width='40' height='40'></td>
		  <td bgcolor=#ffffff class=other>$name</td>
		  <td bgcolor=#ffffff class=other>$t</td> 
		  <td bgcolor=#ffffff class=other><form action='http://www.eaglelegend.com/mystore.php?action=_additem&id=$id&food=1' method='post'>
		  <input type='text' name='cost' value='$cost' size='5'></td>
		  <td bgcolor=#ffffff class=other>$points</td>
		  <td bgcolor=#ffffff class=other>$damage</td>
		  <td bgcolor=#ffffff class=other>
<INPUT TYPE=\"submit\" class='text_box'
VALUE=\"Add to Inventory\"
onClick=\"this.disabled=true;return true;\">
</FORM>			  
		  </td>
		 </tr>";	
		}

		print "</table>";
	}

	if($a == '_additem') {
	 	$id = $_GET['id'];
	 	$food = $_GET['food'];
	 	$cost = $_POST['cost'];

	 	$id2 = $id;

		if($food == 1) {
	 	$sql = mysql_query("SELECT * FROM `fooditems` WHERE `id`='$id' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
	}
	else {
	 	$sql = mysql_query("SELECT * FROM `items` WHERE `equipped`='0' AND `id`='$id' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
	}

	while($row = mysql_fetch_array($sql)) {
	 	extract($row);

		if($food == 1) {

				$insert = mysql_query("INSERT INTO `store_food` (`site`, `store_user`, `name`, `cost`, `points`, `item`) VALUES(\"$Z\", '{$_COOKIE['ELv2']}', \"$name\", '$cost', '$points', \"$item\")");

			}
			else {

			$insert = mysql_query("INSERT INTO `store_items` (`site`, `store_user`, `name`, `cost`, `points`, `damage`, `type`, `item`) VALUES(\"$Z\", '{$_COOKIE['ELv2']}', \"$name\", '$cost', '$points', '$damage', '$type', \"$item\")");			 
			}	 	
	}

	if($insert) {
		if($food == 1) {
		 	$delete = mysql_query("DELETE FROM `fooditems` WHERE `id`='$id2' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
		}
		else {
		 	$delete = mysql_query("DELETE FROM `items` WHERE `id`='$id2' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
		}

		if($delete) {
		 	print "<h2>Item Added!</h2><p>
			This item has been added to your inventory!<p>
			<a href='http://www.eaglelegend.com/mystore.php'>Back to My Store</a>";
		}
		else {
		 	print mysql_error();
		} 
	}
	else {
	 	print mysql_error();
	}
	}

	if($a == 'update') {
	$store_name = $_POST['store_name'];
	$open = $_POST['open']; 
	$img = $_FILES['image'];

	if($img) {
 while(list($key,$value) = each($_FILES[image][name])) {
 	if(!empty($value)){   // this will check if any blank field is entered
		$filename = $value;    // filename stores the value

		$path = $items_path . "http://www.eaglelegend.com/storeimages";

		$path_parts = pathinfo($path . "http://www.eaglelegend.com/" . $filename);	//get the file type
		$typer = $path_parts["extension"];

		$add = $path . "http://www.eaglelegend.com/" . $filename;   // upload directory path is set

		copy($_FILES[image][tmp_name][$key], $add);     //  upload the file to the server

		$r = rand(1,9999999);
		$user = $_COOKIE['ELv2'];

		$newname = $path . "http://www.eaglelegend.com/" . $user . "_" . $r . "." . $typer;

		$file_name = "http://www.eaglelegend.com/" . $user . "_" . $r . "." . $typer;

				if(rename($add,$newname)) {
					 	$sql1 = mysql_query("UPDATE `stores` SET `store_image`=\"$file_name\" WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");
						if(!$sql1) {
						 	print mysql_error();
						}
				}
				else {
				 	print "File could not be uploaded!";
				}
	}
}		 
	}

	$update = mysql_query("UPDATE `stores` SET `open`='$open', `store_name`=\"$store_name\" WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\"");

	if($update) {
	 	Header("Location: http://www.eaglelegend.com/mystore.php");
	}
	else {
	 	print mysql_error();
	}
	}

}

include("footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/105763-upload-image-store-image/
Share on other sites

ok basically, for some reason when the user clicks to get for example a picture of your grandma uploaded on there, when they have clicked what they want to choose, it just goes back to the page they were at and dont upload anything :/, and nothing shows in the box next to the brows, you know you have the browse button on the right and the url box of where that image is located on the left, nothing shows there :/

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.