Jump to content

Newbi - Please Help!


Mac215

Recommended Posts

I really don't have any expereince in php. On my web site users can customize a pc online then check out. How this works is this... User selects a pre configured system or can choose to customize their own. for example, when a user selects a system weather pre configured or a custom built pc, they are sent to a page asking to login, etc ... and the price for the computer is displayed. Then, they are sent to a page asking for more information, address, CC information, etc and the price is displayed on this page as well. here is where the problem comes in. Once they get to the confirmorder page where they confirm all information is correct and and place the order the price is NOT displayed. The price is located at the botton of the page right below the check out button.

 

I'm going to upload the file if anyone could please help, that would be great! i've been going over the file for 13 hours and cannot find the problem. But then again... I have no expereince in PHP and i'm surprised I got this far. I think the code is pretty sloppy, but what can I say.

 

Thank you in advanced for any help you can proved.

 

[attachment deleted by admin]

Link to comment
Share on other sites

I change some of it.

 

If their are any errors in the script post the error message here and the surrounding lines.

 

<?php
function printHiddenVars()
{
$dbcnx = mysql_connect("mysql", "", ""); 
mysql_select_db("mas_products", $dbcnx); 

$result = mysql_query("SELECT id, name FROM component;");

if(!$result)
 	die("<p>Error performing query: " . mysql_error() . "</p>"); 
else
{
	while($row = mysql_fetch_array($result))
	{
		echo "<input type=hidden name=\"".trim($row['name'])."\" value=\"".str_replace("\\\\\\","",$_POST[trim($row['name'])])."\" />\n";
	}
}
mysql_close($dbcnx);	
}

function printOrder()
{
$dbcnx = mysql_connect("mysql", "", ""); 
mysql_select_db("mas_products", $dbcnx); 
$result = mysql_query("SELECT id, name FROM component;");

if(!$result)
 	die("<p>Error performing query: " . mysql_error() . "</p>"); 
else
{
	while($row = mysql_fetch_array($result))
	{
		if(strlen($_POST[trim($row['name'])]) != 0)
			echo "<br />".str_replace("\\\\\\","",$_POST[trim($row['name'])])."\n";
	}
}
mysql_close($dbcnx);	
}

if(isset($_POST['action']))
{
$dbcnx = mysql_connect("mysql", "", ""); 
mysql_select_db("mas_products", $dbcnx); 
$strComments = "";	
$result = mysql_query("SELECT id, name FROM component;");

if(!$result)
	 	die("<p>Error performing query: " . mysql_error() . "</p>"); 
else
{
	while($row = mysql_fetch_array($result))
	{
	$strComments .= $_POST[trim($row['name'])]."\n";
	}
}

$sql = "INSERT INTO user_purchase (Product, BillName, BillAddress, BillAddress2, BillCity, BillState, BillZip, ShipName, ShipAddress, ShipAddress2, ShipCity, ShipState, ShipZip, Email, Phone, CCName, CCNumber, CCType, CCSec, CCExpMonth, CCExpYear, DateCreated, ConfiguredPrice, Comments) VALUES ('".mysql_real_escape_string($_POST['product'])."', '".mysql_real_escape_string($_POST['billname'])."', '".mysql_real_escape_string($_POST['billaddress'])."', '".$_POST['billaddress2']."', '".mysql_real_escape_string($_POST['billcity'])."', '".mysql_real_escape_string($_POST['billstate'])."', '".mysql_real_escape_string($_POST['billzip'])."', '".mysql_real_escape_string($_POST['shipname'])."', '".mysql_real_escape_string($_POST['shipaddress'])."', '".mysql_real_escape_string($_POST['shipaddress2'])."', '".$_POST['shipcity']."', '".mysql_real_escape_string($_POST['shipstate'])."', '".mysql_real_escape_string($_POST['shipzip'])."', '".mysql_real_escape_string($_POST['email'])."', '".mysql_real_escape_string($_POST['phone'])."', '".mysql_real_escape_string($_POST['ccname'])."', '".mysql_real_escape_string($_POST['ccnumber'])."', '".mysql_real_escape_string($_POST['cctype'])."', '".mysql_real_escape_string($_POST['ccsec'])."', '".mysql_real_escape_string($_POST['ccmonth'])."', '".mysql_real_escape_string($_POST['ccyear'])."', NOW(), '".mysql_real_escape_string($_POST['compprice'])."', '".mysql_real_escape_string($strComments)."' ) ";

if(mysql_query($sql))
{
	$ordernumber = mysql_insert_id();
	mail("morrison5891@hotmail.com", "You Have A New Order Waiting", "You have 1 new order waiting. Login to view this order. http://www.ictindy.com/ssl/purchaseview.php \n\n");
	mail("dmorrison@ictindy.com", "You Have A New Order Waiting", "You have 1 new order waiting. Login to view this order. http://www.ictindy.com/ssl/purchaseview.php \n\n");

	mail($_POST['email'], "Your order has been received.", "Your credit card has not been charged yet. You will receive an e-mail when your order has been processed.\n\nYour order number is: ".$ordernumber."\n\nIf you have any questions about your order, please e-mail us at orders@ictindy.com or visit http://www.ictindy.com/ssl/trackorder.php to check the status of your order. Thank You - Extreme PC");

	header("Location: https://p2.secure.hostingprod.com/@ictindy.com/ssl/thankyou.php?ordernumber=".$ordernumber);
}
else
{
	die(mysql_error());
}

mysql_close($dbcnx);
}
else
{
if($_POST['billstate'] == "IN")
{
	$price = $_POST['compprice'];
	$price = round($price * .07 + $price, 2);
}
else
	$price = $_POST['compprice'];
?>
<!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" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Extreme PC - Confirm Order And Check Out</title>
<meta name="robots" content="noindex, nofollow">
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css"> 
<!-- 
body  {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
background-image: url(https://p2.secure.hostingprod.com/@ictindy.com/ssl/Pictures/bg9_3.gif);
}

td {
font: 100% Verdana, Arial, Helvetica, sans-serif;
color: #000;
}

/* Tips for Elastic layouts 
1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust these divs based on your final font sizing.
*/
.twoColElsLt #container { 
width: 910px;  /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
} 

/* Tips for mainContent:
1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs.
2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div.  No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing.
4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur.
*/
.twoColElsLt #mainContent {
	margin: 0 1.5em 0 4px; /* the right margin can be given in ems or pixels. It creates the space down the right side of the page. */
} 

/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}
a:link {
color: #0000FF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #0000FF;
}
.style4 {font-size: xx-small}
.style5 {
font-size: x-small;
font-weight: bold;
}
.style6 {
color: #0000FF;
font-size: small;
}
.style7 {font-size: small}
.style8 {color: #0000FF}
.style10 {font-size: x-small}
.style11 {font-size: 12px; }
.style12 {
color: #FF0000;
font-weight: bold;
}
.twoColElsLt #container #mainContent form table tr td p .style9 .style12 {
color: #00F;
}
.style13 {	font-weight: bold;
font-size: x-small;
}
.style14 {	font-size: small;
color: #0000FF;
font-weight: bold;
}
.dfgdfgg {	color: #000;
}
.style15 {	color: #0000FF;
font-weight: bold;
left: 10px;
}
.style16 {	color: #00F
}
--> 
</style>

<script language=javascript>

function copyBill()
{
	document.getElementById('shipname').value = document.getElementById('billname').value;
	document.getElementById('shipaddress').value = document.getElementById('billaddress').value;
	document.getElementById('shipaddress2').value = document.getElementById('billaddress2').value;
	document.getElementById('shipcity').value = document.getElementById('billcity').value;
//		document.getElementById('shipstate').value = document.getElementById('billstate').value;
document.getElementById('shipstate').selectedIndex = document.getElementById('billstate').selectedIndex;
	document.getElementById('shipzip').value = document.getElementById('billzip').value;
}
</script>


<!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.twoColElsLt #sidebar1 { padding-top: 30px; }
.twoColElsLt #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<body class="twoColElsLt">
<p><img src="https://p2.secure.hostingprod.com/@ictindy.com/ssl/Pictures/header-info.jpg" width="910" height="115" /></p>
<div id="container">
<div id="mainContent" style="width:910px; font-size:x-small; text-align: left; color: #333; font-weight: bold;">
<p align="left">
  <input type="hidden" name="action2" value="submitted" />
  <input type="hidden" name="compprice" value="<?= $price ?>" />
  <input type="hidden" name="product2" value="<?= $_POST['product']; ?>" />
  <?
printHiddenVars();
?>
  <input type="hidden" name="billname2" value="<?= $_POST['billname'] ?>" />
  <input type="hidden" name="billaddress3" value="<?= $_POST['billaddress'] ?>" />
  <input type="hidden" name="billaddress3" value="<?= $_POST['billaddress2'] ?>" />
  <input type="hidden" name="billcity2" value="<?= $_POST['billcity'] ?>" />
  <input type="hidden" name="billstate2" value="<?= $_POST['billstate'] ?>" />
  <input type="hidden" name="billzip2" value="<?= $_POST['billzip'] ?>" />
  <input type="hidden" name="shipname2" value="<?= $_POST['shipname'] ?>" />
  <input type="hidden" name="shipaddress3" value="<?= $_POST['shipaddress'] ?>" />
  <input type="hidden" name="shipaddress3" value="<?= $_POST['shipaddress2'] ?>" />
  <input type="hidden" name="shipcity2" value="<?= $_POST['shipcity'] ?>" />
  <input type="hidden" name="shipstate2" value="<?= $_POST['shipstate'] ?>" />
  <input type="hidden" name="shipzip2" value="<?= $_POST['shipzip'] ?>" />
  <input type="hidden" name="ccname2" value="<?= $_POST['ccname'] ?>" />
  <input type="hidden" name="ccnumber2" value="<?= $_POST['ccnumber'] ?>" />
  <input type="hidden" name="cctype2" value="<?= $_POST['cctype'] ?>" />
  <input type="hidden" name="ccsec2" value="<?= $_POST['ccsec'] ?>" />
  <input type="hidden" name="ccmonth2" value="<?= $_POST['ccmonth'] ?>" />
  <input type="hidden" name="ccyear2" value="<?= $_POST['ccyear'] ?>" />
  <input type="hidden" name="email2" value="<?= $_POST['email'] ?>" />
  <input type="hidden" name="phone2" value="<?= $_POST['phone'] ?>" />
</p>
<p align="left">Selected System: 
  <?= $_POST['product']; ?>
</p>
<p align="left">
  <?
printOrder();
?>
</p>
<hr />
<form method=post action=https://p2.secure.hostingprod.com/@ictindy.com/ssl/confirmorder.php>
  <table border=0 cellpadding=0 cellspacing=0 width=851>
    <tr>
      <td colspan=2> </td></tr>
  <tr><td width="434" valign=top>
  <p><b>Billing Information</b>
  <br />
    <?= $_POST['billname']; ?>
    <br />
    <?= $_POST['billaddress']; ?>
    <br />
    <?= $_POST['billaddress2']; ?>
    <br />
    <?= $_POST['billcity']; ?>
    , 
    <?= $_POST['billstate']; ?> 
    <?= $_POST['billzip']; ?>
  </p></td>
  <td width="377" valign=top>
  <p><b>Shipping Information</b>
    <br />
    <?= $_POST['shipname']; ?>
    <br />
    <?= $_POST['shipaddress']; ?>
    <br />
    <?= $_POST['shipaddress2']; ?>
    <br />
    <?= $_POST['shipcity']; ?>
    , 
    <?= $_POST['shipstate']; ?> 
    <?= $_POST['shipzip']; ?>
  </p>
  <p align="right"><a href="javascript:history.go(-1);" class="style10">Click here to make changes</a></p></td></tr>
  <tr><td colspan=2>
  <p align="left"><span class="style14"> </span></p>
  <hr />
  <p align="left"><span class="style5">Payment information</span> </p>
  <p align="left" class="style4"><span class="style6">Name On Card:</span> <span class="style7">
    <?= $_POST['ccname']; ?>
    <br />
    <span class="style8">Card Type:</span></span> <span class="style7">
      <?= $_POST['cctype']; ?>
      <br />
      <span class="style8">CC Number:</span></span> <span class="style7">
        <?= $_POST['ccnumber']; ?>
        <br />
        <span class="style8">CC Code:</span></span> <span class="style7">
          <?= $_POST['ccsec']; ?>
          <br />
          <span class="style8">Exp. Date:</span></span> <span class="style7">
            <?= $_POST['ccmonth']; ?>/<?= $_POST['ccyear']; ?>
            </span></p>
  <hr />
  <p align="left" class="style11">Shipping: UPS Ground 5 Day Select  </p>
  <p>Price as configured: <span class="style9"><span class="style12">$<?= $price ?> <?= (($_POST['billstate'] == "IN")?"":""); ?>
  </span>  </span></p>
  </p> 
    <p>
      <input type="image"src="https://p2.secure.hostingprod.com/@ictindy.com/ssl/checkout1.gif" />
  <br />
  </p></td></tr></table>
</form></div></p></div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-6282394-2");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
<?		
}
?>

Link to comment
Share on other sites

Thanks for getting back to me so fast.

 

Ok, I checked that out and the price is still not being displayed. Also, now there is a new problem after trying your code. The system the user is going to purchase is displayed at the top of the page. It list all components in the system. Now, its not displaying all components like it did before.

 

Thanks for helping me out!!

Link to comment
Share on other sites

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.