Can you help me with this?
How can i pass the info that I selected from Index.php to productinfo.php ? My friend told me that I should use "post method" but i don't know how to apply it to my code...
here is my code
index.php:
<?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_showproduct = 6;
$pageNum_showproduct = 0;
if (isset($_GET['pageNum_showproduct'])) {
$pageNum_showproduct = $_GET['pageNum_showproduct'];
}
$startRow_showproduct = $pageNum_showproduct * $maxRows_showproduct;
mysql_select_db($database_localhost, $localhost);
$query_showproduct = "SELECT * FROM product";
$query_limit_showproduct = sprintf("%s LIMIT %d, %d", $query_showproduct, $startRow_showproduct, $maxRows_showproduct);
$showproduct = mysql_query($query_limit_showproduct, $localhost) or die(mysql_error());
$row_showproduct = mysql_fetch_assoc($showproduct);
if (isset($_GET['totalRows_showproduct'])) {
$totalRows_showproduct = $_GET['totalRows_showproduct'];
} else {
$all_showproduct = mysql_query($query_showproduct);
$totalRows_showproduct = mysql_num_rows($all_showproduct);
}
$totalPages_showproduct = ceil($totalRows_showproduct/$maxRows_showproduct)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link href="css/mystyle.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div id="container">
<div id="header"></div>
<!-- *************************** MENU -->
<div id="menu">
<ul>
<li><a href="login.php">Login</a></li>
<li><a href="signup.php">Signup</a></li>
<li><a href="#">Home</a></li>
</ul>
</div>
<!-- *************************** CATEGORY -->
<div id="category"><ul>
<li><a href="computers.php"><img src="images/menudesktop.png" width="333" height="100" border="0"/></a></li>
<li><a href="laptops.php"><img src="images/menulaptop.png" width="333" height="100" alt=""/></a></li>
<li><a href="mobiles.php"><img src="images/menumobile.png" width="333" height="100" alt=""/></a></li>
</ul>
</div>
<!-- *************************** BRAND -->
<div id="brand">
<ul>
<li><a href="#">Intel</a></li>
<li><a href="#">Lenovo</a></li>
<li><a href="#">Samsung</a></li>
<li><a href="#">Dell</a></li>
<li><a href="#">Cherry Mobile</a></li>
<li><a href="#">Apple</a></li>
</ul>
</div>
<form id="mainbodyform" name="mainbodyform" method="post" action="productinfo.php">
<!-- *************************** MAINBODY -->
<div id="mainbody">
<!-- *************************** PRODUCT CONTAINER -->
<?php do { ?>
<div id="productcontainer">
<div id="imgbox"></div>
<div id="txtbox">
<table width="250" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><?php echo $row_showproduct['name']; ?></td>
</tr>
<tr>
<td><?php echo $row_showproduct['brand']; ?></td>
</tr>
<tr>
<td><?php echo $row_showproduct['category']; ?></td>
</tr>
<tr>
<td>₱<?php echo $row_showproduct['price']; ?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="Buy Now!" /></td>
</tr>
</table>
</div>
</div>
<?php } while ($row_showproduct = mysql_fetch_assoc($showproduct)); ?>
</div>
</form>
<!-- *************************** FOOTER -->
<div id="footer"><p>Runts & Giants</p></div>
</div>
</body>
</html>
<?php
mysql_free_result($showproduct);
?>
And This is my productinfo.php
<?php @session_start(); ?>
<?php require_once('Connections/localhost.php'); ?>
<?php
$_SESSION['Index.php']=3;
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_localhost, $localhost);
$query_productinfo = "SELECT * FROM product";
$productinfo = mysql_query($query_productinfo, $localhost) or die(mysql_error());
$row_productinfo = mysql_fetch_assoc($productinfo);
$totalRows_productinfo = mysql_num_rows($productinfo);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>layout</title>
<link href="css/mystyle.css" rel="stylesheet" type="text/css" />
<link href="css/productinfostyle.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div id="container">
<div id="header"></div>
<!-- *************************** MENU -->
<div id="menu">
<ul>
<li><a href="#">Order</a></li>
<li><a href="#">Cart</a></li>
<li><a href="#">Home</a></li>
</ul>
</div>
<!-- *************************** CATEGORY -->
<div id="category"><ul>
<li><a href="computers.php"><img src="images/menudesktop.png" width="333" height="100" border="0"/></a></li>
<li><a href="laptops.php"><img src="images/menulaptop.png" width="333" height="100" alt=""/></a></li>
<li><a href="mobiles.php"><img src="images/menumobile.png" width="333" height="100" alt=""/></a></li>
</ul>
</div>
<!-- *************************** BRAND -->
<div id="brand">
<ul>
<li><a href="#">Intel</a></li>
<li><a href="#">Lenovo</a></li>
<li><a href="#">Samsung</a></li>
<li><a href="#">Dell</a></li>
<li><a href="#">Cherry Mobile</a></li>
<li><a href="#">Apple</a></li>
</ul>
</div>
<!-- *************************** MAINBODY -->
<div id="mainbody">
<form id="productform" name="productform.php" method="">
<div id="itemimg">1</div>
<div id="itemdesc"><br />
<br />
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="301"><table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo $row_productinfo['name']; ?></td>
</tr>
<tr>
<td><?php echo $row_productinfo['brand']; ?></td>
</tr>
<tr>
<td><?php echo $row_productinfo['category']; ?></td>
</tr>
<tr>
<td><?php echo $row_productinfo['price']; ?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="Add to Cart" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
<td width="299"><?php echo $row_productinfo['description']; ?></td>
</tr>
</table>
</div>
</form>
</div>
<!-- *************************** FOOTER -->
<div id="footer"><p>Runts & Giants</p></div>
</div>
</body>
</html>
<?php
mysql_free_result($productinfo);
?>
Thanks...