Jump to content

[SOLVED] Page refresh/history problem


DarkPrince2005

Recommended Posts

Ok it took me a while to find, modify and get a shopping cart script that worked and was easy for me to understand, although I am having trrouble with one thing.

 

I have a page that lists the manufacturers of a product and when a manufacturer is selected it directs the user to a page that retrieves the products according to category and manufacturer and then displays them in a list with a button to view the product description, that when this button is clicked it directs the user to another page that retrieves all the apropriate data from the database displays  it, and a button to add to cart. The cart script though use to just take the user to the cart where i modified it to just go back in the history, but it has a problem refreshing and displaying the previous page which retrieved data from the database. Does anyone maybe have a sollution?

 

 

Page listing manufacturers

<?php 
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
header('Cache-Control: no-store, no-cache, must-revalidate'); 
header('Cache-Control: post-check=0, pre-check=0', FALSE); 
header('Pragma: no-cache');

ini_set('display_errors','On');
error_reporting(E_ALL);
ini_set('session.cache_limiter','');
session_start();
$id=session_id();
if(!isset($_SESSION['isLoggedIn']) || (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] != true))
{
mysql_connect("localhost","root","");
mysql_select_db("pc_lan_it");
$sql=mysql_query("SELECT * 
FROM categories
WHERE EXISTS (

SELECT * 
FROM tbl_product
WHERE tbl_product.product_manufacturer = categories.manufacturer
AND tbl_product.category_id LIKE 'notebooks'
)");

echo "<html>
<head>
	<title>Pc,LAN & IT Consulting Web Template</title>

	<style>
	h1{font-size:'13pt';
	}
	  
	.scrollable { 
	width: 650px; 
	height: 95%; 
	overflow: auto;
	background-repeat:no-repeat;
	} 
	 </style>
</head>
<body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' bgcolor='#E4E5E7'>
<center><table cellpadding='0' border='0' cellspacing='0' height='100%'>
<tr>
<td colspan='2' height='110' width='893' background='images/top4.gif' align='right' valign='top'>
				<form name='myform1' action='' method='post'>
				<table height='84' cellpadding='0' cellpadding='0' border='0'>
					<tr>
						<td height='36' valign='top' align='right'>
														   <a href='index.php'><img src='images/home.gif' border='0' class='domroll images/home1.gif' alt='Home'></a>
														   <a href='contact.html'><img src='images/contact.gif' border='0' class='domroll images/contact1.gif' alt='Contact Us'></a>
														   <a href='newsletter.html'><img src='images/news.gif' border='0' class='domroll images/news1.gif' alt='Newsletter'></a>
														   <a href='login.html'><img src='images/login.gif'  border='0' class='domroll images/login1.gif' alt='Login'></a>
														   <a href='order.html'><img src='images/order.gif' border='0' class='domroll images/order1.gif' alt='Order'></a>
														   <a href='cart.php'><img src='images/cart.gif' border='0' class='domroll images/cart1.gif' alt='Shopping Cart'></a>     </td>
					</tr>
					<tr>
					<td valign='center' align='right'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform1.submit()\" onmouseover=\"document.myform1.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform1.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a>   <br>
					<a href='login.php'><b>Login</b></a>    
					</td>
					</tr>
				</table></form>
</td>
</tr>
<tr>
<td width='192' height='408' background='images/categories_nav.gif' valign='top'><center><font size='1'><br><br><br></font>
	<a href='notebooks.php'><img src='images/notebooks.gif' height='36' border='0' class='domroll images/notebooks1.gif' alt='Notebooks'></a><br>
	<a href='desktops.html'><img src='images/desktops.gif' height='36' border='0' class='domroll images/desktops1.gif' alt='Desktops'></a><br>
	<a href='hardware.html'><img src='images/hardware.gif' height='36' border='0' class='domroll images/hardware1.gif' alt='Hardware'></a><br>
	<a href='software.html'><img src='images/software.gif' height='36' border='0' class='domroll images/software1.gif' alt='Software'></a><br>
	<a href='accessories.html'><img src='images/accessories.gif' height='36' border='0' class='domroll images/accessories1.gif' alt='Accessories'></a><br>
	<a href='handhelds.html'><img src='images/handhelds.gif' height='36' border='0' class='domroll images/handhelds1.gif' alt='Handhelds'></a><br>
	<a href='plasmas.html'><img src='images/plasmas.gif' height='36' border='0' class='domroll images/plasmas1.gif' alt='Plasmas'></a><br>
	<a href='projectors.html'><img src='images/projectors.gif' height='36' border='0' class='domroll images/projectors1.gif' alt='Projectors'></a><br>
	<a href='hometheatersystems.html'><img src='images/homet.gif' height='36' border='0' class='domroll images/homet1.gif' alt='Home Theater Systems'></a><br>
	<a href='printersandscanners.html'><img src='images/printers.gif' height='36' border='0' class='domroll images/printers1.gif' alt='Printers & Scanners'></a><br></td>
<td rowspan='2' width='701' valign='top' align='center' background='images/body.gif'><div class='scrollable'>
	<table border='0' height='100%' cellpadding='0' cellspacing='0' width='600'>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>
			<td colspan='5' valign='top' height='40'><h1>Notebook Manufacturers</h1></td>
		</tr>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>";
			while ($row=mysql_fetch_array($sql)){
			echo "<td align='center'><form method='post'><input type='hidden' name='selection' value='$row[manufacturer]' alt='$row[manufacturer]'><input type='image' src='$row[image]' alt='$row[manufacturer]' height='20' onclick=\"this.form.action='hp_notebooks.php';\"></td>
			<td> </td>
			<td colspan='3'>$row[manufacturer]</form></td></tr>";
			}
		echo "
		<tr>
			<td colspan='5'> </td>
		</tr>
		<tr>
			<td colspan='5' align='right' valign='bottom'></td>
		</tr>
	</table></div>
</td>
</tr>
<tr>
<td background='images/search.gif' valign='top' align='center'><center><font size='1'><br><br><br></font>
		<form name='myform' action='' method='post'>
			<table cellpadding='0' cellspacing='0' border='0' width='160'>
				<tr>
					<td valign='center'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform.submit()\" onmouseover=\"document.myform.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a></td>
				</tr>
			</table>
		</form>
</td>
</tr>
<tr>
<td colspan='2' height='24' background='images/bottom.gif'></td>
</tr>
</table>
<script src='js/chrisdomroll.js'>
</script>";}

elseif ($SESSION['isLoggedIn']='true')
{

mysql_connect("localhost","root","");
mysql_select_db("pc_lan_it");
$sql1=mysql_query("SELECT * FROM `tbl_product` order by rand() limit 3");
$sql=mysql_query("SELECT * 
FROM categories
WHERE EXISTS (

SELECT * 
FROM tbl_product
WHERE tbl_product.product_manufacturer = categories.manufacturer
AND tbl_product.category_id LIKE 'notebooks'
)");
$sql2=mysql_query("Select * from tbl_cart where cart_session_id like '$id'");
$a=mysql_num_rows($sql1);
echo "<html>
<head>
	<title>Pc,LAN & IT Consulting Web Template</title>

	<style>
	h1{font-size:'13pt';
	}
	  
	.scrollable { 
	width: 650px; 
	height: 95%; 
	overflow: auto;
	background-repeat:no-repeat;
	} 
	 </style>
</head>
<body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' bgcolor='#E4E5E7'>
<center><table cellpadding='0' border='0' cellspacing='0' height='100%'>
<tr>
<td colspan='2' height='110' width='893' background='images/top4.gif' align='right' valign='top'>
				<form name='myform1' action='' method='post'>
				<table height='84' cellpadding='0' cellpadding='0' border='0'>
					<tr>
						<td height='36' valign='top' align='right'>
														   <a href='index.php'><img src='images/home.gif' border='0' class='domroll images/home1.gif' alt='Home'></a>
														   <a href='contact.html'><img src='images/contact.gif' border='0' class='domroll images/contact1.gif' alt='Contact Us'></a>
														   <a href='newsletter.html'><img src='images/news.gif' border='0' class='domroll images/news1.gif' alt='Newsletter'></a>
														   <a href='login.html'><img src='images/login.gif'  border='0' class='domroll images/login1.gif' alt='Login'></a>
														   <a href='order.html'><img src='images/order.gif' border='0' class='domroll images/order1.gif' alt='Order'></a>
														   <a href='cart.php'><img src='images/cart.gif' border='0' class='domroll images/cart1.gif' alt='Shopping Cart'></a>     </td>
					</tr>
					<tr>
					<td valign='center' align='right'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform1.submit()\" onmouseover=\"document.myform1.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform1.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a>   <br>
					<a href='login.php'><b>Login</b></a>    
					</td>
					</tr>
				</table></form>
</td>
</tr>
<tr>
<td width='192' height='408' background='images/categories_nav.gif' valign='top'><center><font size='1'><br><br><br></font>
	<a href='notebooks.php'><img src='images/notebooks.gif' height='36' border='0' class='domroll images/notebooks1.gif' alt='Notebooks'></a><br>
	<a href='desktops.html'><img src='images/desktops.gif' height='36' border='0' class='domroll images/desktops1.gif' alt='Desktops'></a><br>
	<a href='hardware.html'><img src='images/hardware.gif' height='36' border='0' class='domroll images/hardware1.gif' alt='Hardware'></a><br>
	<a href='software.html'><img src='images/software.gif' height='36' border='0' class='domroll images/software1.gif' alt='Software'></a><br>
	<a href='accessories.html'><img src='images/accessories.gif' height='36' border='0' class='domroll images/accessories1.gif' alt='Accessories'></a><br>
	<a href='handhelds.html'><img src='images/handhelds.gif' height='36' border='0' class='domroll images/handhelds1.gif' alt='Handhelds'></a><br>
	<a href='plasmas.html'><img src='images/plasmas.gif' height='36' border='0' class='domroll images/plasmas1.gif' alt='Plasmas'></a><br>
	<a href='projectors.html'><img src='images/projectors.gif' height='36' border='0' class='domroll images/projectors1.gif' alt='Projectors'></a><br>
	<a href='hometheatersystems.html'><img src='images/homet.gif' height='36' border='0' class='domroll images/homet1.gif' alt='Home Theater Systems'></a><br>
	<a href='printersandscanners.html'><img src='images/printers.gif' height='36' border='0' class='domroll images/printers1.gif' alt='Printers & Scanners'></a><br></td>
<td rowspan='2' width='701' valign='top' align='center' background='images/body.gif'><div class='scrollable'>
	<table border='0' height='100%' cellpadding='0' cellspacing='0' width='600'>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>
			<td colspan='5' valign='top' height='40'><h1>Notebook Manufacturers</h1></td>
		</tr>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>";
			while ($row=mysql_fetch_array($sql)){
			echo "<td align='center'><form method='post'><input type='hidden' name='selection' value='$row[manufacturer]' alt='$row[manufacturer]'><input type='image' src='$row[image]' alt='$row[manufacturer]' height='20' onclick=\"this.form.action='hp_notebooks.php';\"></td>
			<td> </td>
			<td colspan='3'>$row[manufacturer]</form></td></tr>";
			}
		echo "
		<tr>
			<td colspan='5'> </td>
		</tr>
		<tr>
			<td colspan='5' align='right' valign='bottom'></td>
		</tr>
	</table></div>
</td>
</tr>
<tr>
<td background='images/search.gif' valign='top' align='center'><center><font size='1'><br><br><br></font>
		<form name='myform' action='' method='post'>
			<table cellpadding='0' cellspacing='0' border='0' width='160'>
				<tr>
					<td valign='center'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform.submit()\" onmouseover=\"document.myform.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a></td>
				</tr>
			</table>
		</form>
</td>
</tr>
<tr>
<td colspan='2' height='24' background='images/bottom.gif'></td>
</tr>
</table>
<script src='js/chrisdomroll.js'>
</script>";}
?>

 

 

Page retrieving products according to selected manufacturer

<?php

ini_set('display_errors','On');
error_reporting(E_ALL);
ini_set('session.cache_limiter','');
session_start();
$id=session_id();
if(!isset($_SESSION['isLoggedIn']) || (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] != true))
{
mysql_connect("localhost","root","");
mysql_select_db("pc_lan_it");
$sql=mysql_query("SELECT * 
FROM tbl_product where product_manufacturer like '$_POST[selection]' and category_id like 'Notebooks'");

echo "<html>
<head>
	<title>Pc,LAN & IT Consulting Web Template</title>

	<style>
	h1{font-size:'13pt';
	}
	  
	.scrollable { 
	width: 650px; 
	height: 95%; 
	overflow: auto;
	background-repeat:no-repeat;
	} 
	 </style>
</head>
<body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' bgcolor='#E4E5E7'>
<center><table cellpadding='0' border='0' cellspacing='0' height='100%'>
<tr>
<td colspan='2' height='110' width='893' background='images/top4.gif' align='right' valign='top'>
				<form name='myform1' action='' method='post'>
				<table height='84' cellpadding='0' cellpadding='0' border='0'>
					<tr>
						<td height='36' valign='top' align='right'>
														   <a href='index.php'><img src='images/home.gif' border='0' class='domroll images/home1.gif' alt='Home'></a>
														   <a href='contact.html'><img src='images/contact.gif' border='0' class='domroll images/contact1.gif' alt='Contact Us'></a>
														   <a href='newsletter.html'><img src='images/news.gif' border='0' class='domroll images/news1.gif' alt='Newsletter'></a>
														   <a href='login.html'><img src='images/login.gif'  border='0' class='domroll images/login1.gif' alt='Login'></a>
														   <a href='order.html'><img src='images/order.gif' border='0' class='domroll images/order1.gif' alt='Order'></a>
														   <a href='cart.php'><img src='images/cart.gif' border='0' class='domroll images/cart1.gif' alt='Shopping Cart'></a>     </td>
					</tr>
					<tr>
					<td valign='center' align='right'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform1.submit()\" onmouseover=\"document.myform1.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform1.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a>   <br>
					<a href='login.php'><b>Login</b></a>    
					</td>
					</tr>
				</table></form>
</td>
</tr>
<tr>
<td width='192' height='408' background='images/categories_nav.gif' valign='top'><center><font size='1'><br><br><br></font>
	<a href='notebooks.php'><img src='images/notebooks.gif' height='36' border='0' class='domroll images/notebooks1.gif' alt='Notebooks'></a><br>
	<a href='desktops.html'><img src='images/desktops.gif' height='36' border='0' class='domroll images/desktops1.gif' alt='Desktops'></a><br>
	<a href='hardware.html'><img src='images/hardware.gif' height='36' border='0' class='domroll images/hardware1.gif' alt='Hardware'></a><br>
	<a href='software.html'><img src='images/software.gif' height='36' border='0' class='domroll images/software1.gif' alt='Software'></a><br>
	<a href='accessories.html'><img src='images/accessories.gif' height='36' border='0' class='domroll images/accessories1.gif' alt='Accessories'></a><br>
	<a href='handhelds.html'><img src='images/handhelds.gif' height='36' border='0' class='domroll images/handhelds1.gif' alt='Handhelds'></a><br>
	<a href='plasmas.html'><img src='images/plasmas.gif' height='36' border='0' class='domroll images/plasmas1.gif' alt='Plasmas'></a><br>
	<a href='projectors.html'><img src='images/projectors.gif' height='36' border='0' class='domroll images/projectors1.gif' alt='Projectors'></a><br>
	<a href='hometheatersystems.html'><img src='images/homet.gif' height='36' border='0' class='domroll images/homet1.gif' alt='Home Theater Systems'></a><br>
	<a href='printersandscanners.html'><img src='images/printers.gif' height='36' border='0' class='domroll images/printers1.gif' alt='Printers & Scanners'></a><br></td>
<td rowspan='2' width='701' valign='top' align='center' background='images/body.gif'><div class='scrollable'>
	<table border='0' height='100%' cellpadding='0' cellspacing='0' width='600'>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>
			<td colspan='5' valign='top' height='40'><h1>$_POST[selection] Notebooks</h1></td>
		</tr>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		";
			while ($row=mysql_fetch_array($sql)){
			echo "<tr><td  valign='center' align='center' width='300' height='40'><form method='post'><input type='hidden' name='product_id' value='$row[product_id]'><img src='$row[product_image]' border='0' alt='$row[product_name]' width='30%'></td>
			<td> </td>
			<td valign='top'><input type='hidden' name='product_name' value='$row[product_name]'>$row[product_name]<br><small><input type='hidden' name='product_price' value='$row[product_price]'>R $row[product_price]</small></td>
			<td> </td>
			<td valign='center'><input type='image' src='images/details.gif' value='View Details' alt='View Details' onclick=\"this.form.action='product_details.php';\"><br>
								<input type='image' src='images/placeorder.gif' value='Order' alt='Order' onclick=\"this.form.action='2.php';\"><br>
								<input type='hidden' name='qty' value='1'>
								<input type='image' src='images/addtocart.gif' value='Add To Cart' alt='Add To Cart' onclick=\"this.form.action='modcart.php?action=add';\"></form></td>
		</tr>
		<tr>
			<td colspan='5'> </td></tr>";
			}
		echo "
		<tr>
			<td colspan='5'> </td>
		</tr>
		<tr>
			<td colspan='5' align='right' valign='bottom'></td>
		</tr>
	</table></div>
</td>
</tr>
<tr>
<td background='images/search.gif' valign='top' align='center'><center><font size='1'><br><br><br></font>
		<form name='myform' action='' method='post'>
			<table cellpadding='0' cellspacing='0' border='0' width='160'>
				<tr>
					<td valign='center'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform.submit()\" onmouseover=\"document.myform.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a></td>
				</tr>
			</table>
		</form>
</td>
</tr>
<tr>
<td colspan='2' height='24' background='images/bottom.gif'></td>
</tr>
</table>
<script src='js/chrisdomroll.js'>
</script>";}

elseif ($SESSION['isLoggedIn']='true')
{
//$sql1=mysql_query("Select * from tbl_cart where cart_session_id like '$id'");
mysql_connect("localhost","root","");
mysql_select_db("pc_lan_it");
$sql=mysql_query("SELECT * 
FROM tbl_product where product_manufacturer like '$_POST[selection]' and category_id like 'Notebooks'");

echo "<html>
<head>
	<title>Pc,LAN & IT Consulting Web Template</title>

	<style>
	h1{font-size:'13pt';
	}
	  
	.scrollable { 
	width: 650px; 
	height: 95%; 
	overflow: auto;
	background-repeat:no-repeat;
	} 
	 </style>
</head>
<body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' bgcolor='#E4E5E7'>
<center><table cellpadding='0' border='0' cellspacing='0' height='100%'>
<tr>
<td colspan='2' height='110' width='893' background='images/top4.gif' align='right' valign='top'>
				<form name='myform1' action='' method='post'>
				<table height='84' cellpadding='0' cellpadding='0' border='0'>
					<tr>
						<td height='36' valign='top' align='right'>
														   <a href='index.php'><img src='images/home.gif' border='0' class='domroll images/home1.gif' alt='Home'></a>
														   <a href='contact.html'><img src='images/contact.gif' border='0' class='domroll images/contact1.gif' alt='Contact Us'></a>
														   <a href='newsletter.html'><img src='images/news.gif' border='0' class='domroll images/news1.gif' alt='Newsletter'></a>
														   <a href='login.html'><img src='images/login.gif'  border='0' class='domroll images/login1.gif' alt='Login'></a>
														   <a href='order.html'><img src='images/order.gif' border='0' class='domroll images/order1.gif' alt='Order'></a>
														   <a href='cart.php'><img src='images/cart.gif' border='0' class='domroll images/cart1.gif' alt='Shopping Cart'></a>     </td>
					</tr>
					<tr>
					<td valign='center' align='right'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform1.submit()\" onmouseover=\"document.myform1.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform1.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a>   <br>
					<a href='login.php'><b>Login</b></a>    
					</td>
					</tr>
				</table></form>
</td>
</tr>
<tr>
<td width='192' height='408' background='images/categories_nav.gif' valign='top'><center><font size='1'><br><br><br></font>
	<a href='notebooks.php'><img src='images/notebooks.gif' height='36' border='0' class='domroll images/notebooks1.gif' alt='Notebooks'></a><br>
	<a href='desktops.html'><img src='images/desktops.gif' height='36' border='0' class='domroll images/desktops1.gif' alt='Desktops'></a><br>
	<a href='hardware.html'><img src='images/hardware.gif' height='36' border='0' class='domroll images/hardware1.gif' alt='Hardware'></a><br>
	<a href='software.html'><img src='images/software.gif' height='36' border='0' class='domroll images/software1.gif' alt='Software'></a><br>
	<a href='accessories.html'><img src='images/accessories.gif' height='36' border='0' class='domroll images/accessories1.gif' alt='Accessories'></a><br>
	<a href='handhelds.html'><img src='images/handhelds.gif' height='36' border='0' class='domroll images/handhelds1.gif' alt='Handhelds'></a><br>
	<a href='plasmas.html'><img src='images/plasmas.gif' height='36' border='0' class='domroll images/plasmas1.gif' alt='Plasmas'></a><br>
	<a href='projectors.html'><img src='images/projectors.gif' height='36' border='0' class='domroll images/projectors1.gif' alt='Projectors'></a><br>
	<a href='hometheatersystems.html'><img src='images/homet.gif' height='36' border='0' class='domroll images/homet1.gif' alt='Home Theater Systems'></a><br>
	<a href='printersandscanners.html'><img src='images/printers.gif' height='36' border='0' class='domroll images/printers1.gif' alt='Printers & Scanners'></a><br></td>
<td rowspan='2' width='701' valign='top' align='center' background='images/body.gif'><div class='scrollable'>
	<table border='0' height='100%' cellpadding='0' cellspacing='0' width='600'>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		<tr>
			<td colspan='5' valign='top' height='40'><h1>$_POST[selection] Notebooks</h1></td>
		</tr>
		<tr>
			<td colspan='5' height='40'> </td>
		</tr>
		";
			while ($row=mysql_fetch_array($sql)){
			echo "<tr><td  valign='center' align='center' width='300' height='40'><form method='post'><input type='hidden' name='product_id' value='$row[product_id]'><img src='$row[product_image]' border='0' alt='$row[product_name]' width='30%'></td>
			<td> </td>
			<td valign='top'><input type='hidden' name='product_name' value='$row[product_name]'>$row[product_name]<br><small><input type='hidden' name='product_price' value='$row[product_price]'>R $row[product_price]</small></td>
			<td> </td>
			<td valign='center'><input type='image' src='images/details.gif' value='View Details' alt='View Details' onclick=\"this.form.action='product_details.php';\"><br>
								<input type='image' src='images/placeorder.gif' value='Order' alt='Order' onclick=\"this.form.action='2.php';\"><br>
								<input type='hidden' name='qty' value='1'>
								<input type='image' src='images/addtocart.gif' value='Add To Cart' alt='Add To Cart' onclick=\"this.form.action='modcart.php?action=add';\"></form></td>
		</tr>
		<tr>
			<td colspan='5'> </td></tr>";
			}
		echo "
		<tr>
			<td colspan='5'> </td>
		</tr>
		<tr>
			<td colspan='5' align='right' valign='bottom'></td>
		</tr>
	</table></div>
</td>
</tr>
<tr>
<td background='images/search.gif' valign='top' align='center'><center><font size='1'><br><br><br></font>
		<form name='myform' action='' method='post'>
			<table cellpadding='0' cellspacing='0' border='0' width='160'>
				<tr>
					<td valign='center'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform.submit()\" onmouseover=\"document.myform.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a></td>
				</tr>
			</table>
		</form>
</td>
</tr>
<tr>
<td colspan='2' height='24' background='images/bottom.gif'></td>
</tr>
</table>
<script src='js/chrisdomroll.js'>
</script>";}
?>

 

Page displaying product details

<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
header('Cache-Control: no-store, no-cache, must-revalidate'); 
header('Cache-Control: post-check=0, pre-check=0', FALSE); 
header('Pragma: no-cache');

mysql_connect("localhost","root","");
mysql_select_db("pc_lan_it");
$id=$_GET['product_id'];
$sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'");

session_start();

echo "<html>
<head>
	<title>Pc,LAN & IT Consulting Web Template</title>

	<style>
	h1{font-size:'13pt';
	}
	  
	.scrollable { 
	width: 650px; 
	height: 95%; 
	overflow: auto;
	background-repeat:no-repeat;
	} 
	 </style>";
	 echo "<script src=\"js/chrisdomroll.js\">";
echo "</script>";
echo "
</head>
<body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' bgcolor='#E4E5E7'>
<center><table cellpadding='0' border='0' cellspacing='0' height='100%'>
<tr>
<td colspan='2' height='110' width='893' background='images/top4.gif' align='right' valign='top'>
				<form name='myform1' action='' method='post'>
				<table height='84' cellpadding='0' cellpadding='0' border='0'>
					<tr>
						<td height='36' valign='top' align='right'>
														   <a href='index.php'><img src='images/home.gif' border='0' class=\"domroll images/home1.gif\" alt='Home'></a>
														   <a href='contact.html'><img src='images/contact.gif' border='0' class=\"domroll images/contact1.gif\" alt='Contact Us'></a>
														   <a href='newsletter.html'><img src='images/news.gif' border='0' class='domroll images/news1.gif' alt='Newsletter'></a>
														   <a href='login.html'><img src='images/login.gif'  border='0' class='domroll images/login1.gif' alt='Login'></a>
														   <a href='order.html'><img src='images/order.gif' border='0' class='domroll images/order1.gif' alt='Order'></a>
														   <a href='cart.php'><img src='images/cart.gif' border='0' class='domroll images/cart1.gif' alt='Shopping Cart'></a>     </td>
					</tr>
					<tr>
					<td valign='center' align='right'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform1.submit()\" onmouseover=\"document.myform1.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform1.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a>   <br>
					<a href=''>Advanced Search</a>           </td></td>
					</tr>
				</table></form>
</td>
</tr>
<tr>
<td width='192' height='408' background='images/categories_nav.gif' valign='top'><center><font size='1'><br><br><br></font>
	<a href='notebooks.html'><img src='images/notebooks.gif' height='36' border='0' class='domroll images/notebooks1.gif' alt='Notebooks'></a><br>
	<a href='desktops.html'><img src='images/desktops.gif' height='36' border='0' class='domroll images/desktops1.gif' alt='Desktops'></a><br>
	<a href='hardware.html'><img src='images/hardware.gif' height='36' border='0' class='domroll images/hardware1.gif' alt='Hardware'></a><br>
	<a href='software.html'><img src='images/software.gif' height='36' border='0' class='domroll images/software1.gif' alt='Software'></a><br>
	<a href='accessories.html'><img src='images/accessories.gif' height='36' border='0' class='domroll images/accessories1.gif' alt='Accessories'></a><br>
	<a href='handhelds.html'><img src='images/handhelds.gif' height='36' border='0' class='domroll images/handhelds1.gif' alt='Handhelds'></a><br>
	<a href='plasmas.html'><img src='images/plasmas.gif' height='36' border='0' class='domroll images/plasmas1.gif' alt='Plasmas'></a><br>
	<a href='projectors.html'><img src='images/projectors.gif' height='36' border='0' class='domroll images/projectors1.gif' alt='Projectors'></a><br>
	<a href='hometheatersystems.html'><img src='images/homet.gif' height='36' border='0' class='domroll images/homet1.gif' alt='Home Theater Systems'></a><br>
	<a href='printersandscanners.html'><img src='images/printers.gif' height='36' border='0' class='domroll images/printers1.gif' alt='Printers & Scanners'></a><br></td>
<td rowspan='2' width='701' valign='top' align='left' background='images/body.gif'><div class='scrollable'>
	<table border='0' cellpadding='0' cellspacing='0' width='600'>
		<tr>
			<td colspan='5'> </td>
		</tr>";
if (mysql_num_rows($sql)==0){
echo "<tr>
			<td colspan='5' align='center'>There are no products in this category</td>
		</tr>
		<tr>
			<td colspan='5'> </td>
		</tr>
";}
else
{
while ($row = mysql_fetch_array($sql)) 
{
echo "<tr>
			<td  valign='top' align='center' width='300'><form method='post' action=''>
			<input type='hidden' name='product_id' value='$row[product_id]'><br><br><img src='$row[product_image]' border='0' alt='$row[product_name]' width='50%'></td>

			<td> </td>
			<td valign='top'><table>
							 <tr>
								<td colspan='3'><b>Product Name:</b><br></td></tr>
								<tr><td colspan='3'> $row[product_name]</td></tr>
								<tr><td colspan='3'><b>Product Number:</b></td></tr>
							 <tr><td colspan='3'> $row[product_id]</td></tr>
							 <tr><td colspan='3'><b>Price</b></td></tr>
							 <tr><td colspan='3'> <small>R $row[product_price]</small></td></tr>
							 <tr><td colspan='3'><b>Details:</b></td></tr>
							 <tr><td colspan='3'>";$x=explode(",",$row[product_description]);

foreach ($x as $Y)
{
echo $Y." </br>";
}
echo "<br></td></tr>
							 <tr><td colspan='3'> </td></tr>
							 <tr><td><small><b>Quantity:</b></small></td>
							 <td><select name='qty'><option value='1'>1</option>
																						  <option value='2'>2</option>
																						  <option value='3'>3</option>
																						  <option value='4'>4</option>
																						  <option value='5'>5</option>
																						  <option value='6'>6</option>
																						  <option value='7'>7</option>
																						  <option value='8'>8</option>
																						  <option value='9'>9</option>
																						  <option value='10'>10</option></select></td>
							<td><input type='image' src='images/addtocart.gif' value='Add To Cart' alt='Add To Cart' onclick=\"this.form.action='modcart.php?action=add';\"></td></tr></table></td>
			<td> </td>
			<td valign='center'></td>
		</tr>
		</form>
		<tr>
			<td colspan='5'> </td>
		</tr>
";}}
		echo "
	</table></div>
</td>
</tr>
<tr>
<td background='images/search.gif' valign='top' align='center'><center><font size='1'><br><br><br></font>
		<form name='myform' action='' method='post'>
			<table cellpadding='0' cellspacing='0' border='0' width='160'>
				<tr>
					<td valign='center'><input type='text' size='15' name='search'>  <a href=\"javascript:document.myform.submit()\" onmouseover=\"document.myform.sub_but.src='images/search11.gif'\" onmouseout=\"document.myform.sub_but.src='images/search1.gif'\"><img src='images/search1.gif' border='0' name='sub_but' alt='Search'></a></td>
				</tr>
			</table>
		</form>
</td>
</tr>
<tr>
<td colspan='2' height='24' background='images/bottom.gif'></td>
</tr>
</table>";
echo "<script src=\"js/chrisdomroll.js\">";
echo "</script>";
?>

 

Cart functions page

<?php
session_start();
$connect = mysql_connect("localhost", "root", "") 
  or die("Hey loser, check your server connection.");
mysql_select_db("pc_lan_it");

if (isset($_POST['qty'])) {
  $qty = $_POST['qty'];
}
if (isset($_POST['products_prodnum'])) {
  $prodnum = $_POST['products_prodnum'];
}
if (isset($_POST['modified_hidden'])) {
   $modified_hidden = $_POST['modified_hidden'];
}
if (isset($_POST['modified_quan'])) {
  $modified_quan = $_POST['modified_quan'];
}
$sess = session_id();
$action = $_REQUEST['action'];

switch ($action) {
  case "add":
$check = mysql_query("select * from tbl_cart where product_id like '$_POST[product_id]' and cart_session_id like '$sess'");
if (mysql_num_rows($check) < 1){
    $query = "INSERT INTO tbl_cart (
              cart_id, 
              product_id,
		  cart_qty,
		  cart_session_id,
		  cart_date)
              VALUES ('','$_POST[product_id]','$_POST[qty]','$sess',now())";
		  }
		  else
		  {
$query = "update tbl_cart set cart_qty = cart_qty+$_POST[qty] where product_id like '$_POST[product_id]' and cart_session_id like '$sess'";
    //$message = "<div align=\"center\"><strong>Item 
     //           added.</strong></div>";
 }
    break;

  case "change":
    $query = "UPDATE tbl_cart
              SET cart_qty = '$modified_quan'
             WHERE cart_id = '$modified_hidden'";
   // $message = "<div align='center'><strong>Quantity 
     //           changed.</strong></div>";
    break;

  case "delete":
    $query = "DELETE FROM tbl_cart 
              WHERE cart_id like '$_POST[modified_hidden]'";
    //$message = "<div align='center'><strong>Item 
      //          deleted.</strong></div>";
    break;

  case "empty":
    $query = "DELETE FROM tbl_cart WHERE cart_session_id = '$sess'";
    //$message = "<div align='center'><strong>Cart 
      //          emptied.</strong></div>";
    break;

}

$results = mysql_query($query)
  or die(mysql_error());

echo $message;

[u][b]echo "<script language=javascript>history.back(-1)</script>";[/b][/u]
//echo "<a href=\"javascript:history.back(-1)\"></a>";
//include("cart.php");
?>

 

Link to comment
https://forums.phpfreaks.com/topic/120334-solved-page-refreshhistory-problem/
Share on other sites

Sorry, but here is the code.

 

echo "<script language=javascript>history.back(-1)</script>";
//include("cart.php");

 

This is the code at the end of the script that contains  the functions to add,delete,or modify the contents of the cart. It use to just take the user to the cart.php script which displayed the entire cart after the appropriate action has been completed. But I'm having trouble going back to the product details page and having it display without refreshing/resending data

That is also just working like the other javascript. I can't understand it. When viewing the list of products by manufacturer page and clicking on 'add to cart' which executes exactly the same script, it has no problem. But as soon as you view the product details and then click on 'add to cart' it bombes out. Why?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.