Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need PHPer to help fix/dev Small shop script
Old 01-07-2008, 11:42 AM Need PHPer to help fix/dev Small shop script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Hey,

Just wondering if any of you whcih are good with PHP would mind having a look at the shop script i been working on it and help work out some of the bugs.

Thanks,
Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 01-07-2008, 12:56 PM Re: Need PHPer to help fix/dev Small shop script
andyp's Avatar
Extreme Talker

Posts: 165
Name: andy patterson
Trades: 0
Could We See The Script? It Would Be Very Helpful
andyp is offline
Reply With Quote
View Public Profile
 
Old 01-07-2008, 01:26 PM Re: Need PHPer to help fix/dev Small shop script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i guess, i was hoping for someone who would be willing to help through msn tho

Okay, well the script(s) are at http://uk.calmcharity.org/shop/

here is index.php (or the shop front)
PHP Code:
<?php
require('../includes/includes.php');
$pgtitle 'Shop';
session_start();
$extraheader '
<link rel="stylesheet" href="/js/lightbox/css/lightbox.css" type="text/css" media="screen" />
<script src="/js/lightbox/js/prototype.js" type="text/javascript"></script>
<script src="/js/lightbox/js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="/js/lightbox/js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
.product { float:left; width: 99%; border:1px solid #C2DFEE; padding:5px; margin:2px 0 0 0;}
.product img {border:0; padding:0; margin:0 0 0 20px; float:right}
.product_details {clear:both; width:90%; padding:0; margin:0;}
.product_details ul { list-style:none; padding:0; margin:0;}
.product_details li {float:left; padding:0; margin:0 10px 0 0; text-align:center;}
</style>
'
;
$content '<p></p>';
$sessid session_id();
$content .= '<div style="float: left; width: 69%">';
// IF submit new add to basket
if(isset($_POST['addtobasket']))
{
$b_product_id mysql_real_escape_string($_POST['product_id']);
$b_qty mysql_real_escape_string($_POST['qty']);
$datetime date('Y-m-d H:i:s');
$b_res mysql_query("SELECT * FROM shop_baskets WHERE sid='$sessid' AND product_id='$b_product_id'") or die("ERROR" .mysql_error());
$p_in_b mysql_num_rows($b_res);
if(
$p_in_b == 1)
{
$row=mysql_fetch_array($b_res);
$b_p_qty $row['product_qty'];
$b_qty $b_qty $b_p_qty// ADD BASKET TO LATEST BASKET QTY
mysql_query("UPDATE shop_baskets SET sid='$sessid', product_id='$b_product_id', product_qty='$b_qty', add_time='$datetime'") or die("ERROR" .mysql_error());
}
else 
{
mysql_query("INSERT INTO shop_baskets SET sid='$sessid', product_id='$b_product_id', product_qty='$b_qty', add_time='$datetime'") or die("ERROR" .mysql_error());
}
$content .= '<div style="">
Product Added To Basket 
<a href="/shop/basket.php" title="Go to basket">View Basket</a> Or 
<a href="/shop/order.php" title="Order Now">Place Order</a></div>'
;
}
// END add to basket

//This checks to see if there is a page number. If not, it will set it to page 1 
if (!isset($_GET['pagenum']))

$pagenum 1

else { 
$pagenum $_GET['pagenum'];
}
//Here we count the number of results 
//Edit $data to be your query 
$result mysql_query("SELECT * FROM shop_products") or die('Error retrieveing product information. Contact Admin.'.mysql_error());
$rows mysql_num_rows($result); 
//This is the number of results displayed per page 
$page_rows 3
//This tells us the page number of our last page 
$last ceil($rows/$page_rows); 
//this makes sure the page number isn't below one, or more than our maximum pages 
if ($pagenum 1

$pagenum 1

elseif (
$pagenum $last

$pagenum $last

//This sets the range to display in our query 
$max 'LIMIT ' .($pagenum 1) * $page_rows .',' .$page_rows
//This is your query again, the same one... the only difference is we add $max into it
$result mysql_query("SELECT * FROM shop_products ORDER BY product_price DESC $max") or die('Error retrieveing event information. Contact Admin.'.mysql_error());
//This is where you display your query results
while ($row=mysql_fetch_array($result)) {
$content .= '
<form action="index.php" method="post">
<div class="product">
<input type="hidden" name="product_id" value="'
.$row['product_id'].'" />
<a href="'
.$row['product_pic'].'" title="" rel="lightbox"><img src="'.$row['product_pic'].'" width="120" /></a>
<h3>'
.$row['product_name'].'</h3>
<p>
'
.$row['product_desc'].'
<br />
<br />
'
.$row['product_size'].'<br />
<br />
</p>
    
<div class="product_details">
<ul>'
;
//IF options is set show.
if(!empty($row['option']))
{
$content .= '<li><select name="product_option">';
$options explode(","$row['product_option']);
foreach(
$options as $option)
{
$content .= '<option value="'.$option.'">'.$option.'</option>'."\n"
}
$content .= '</select></li>';
// End options
$content .= '
<li> Price: <span class="greentext">&pound; '
.$row['product_price'].'</span> </li>
<li> Quantity: <input type="text" size="1" name="qty" value="1" class="inputbox" /></li>
<li> <input type="submit" name="addtobasket" value="Add to basket" /> </li>
<li> <a href="order.php" title="Order Now">Order Now</a> </li>
</ul>
</div>
</div>
</form>'
;
}
// This shows the user what page they are on, and the total number of pages$content .= "<p style='padding-left: 22%'> --Page $pagenum of $last-- </p>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum != && $pagenum != 0
{
$content .= " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
$content .= " ";
$previous $pagenum-1;
$content .= " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";

//just a spacer
$content .= "  ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum != $last
{
$next $pagenum+1;
$content .= " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
$content .= " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}  

$content .= '</div>
<div style="float: right; width: 24%; border: 1px solid #000; margin-right: 4px; margin-top: 10px; text-align: center">
<h3><a href="/shop/basket.php" title="Go to your basket">Your Basket:</a></h3>'
;
$basket_res=mysql_query("SELECT * FROM shop_baskets WHERE sid='$sessid'") or die(mysql_error());
while(
$basket_items=mysql_fetch_array($basket_res))
{
$productid $basket_items['product_id'];
$b_product_res=mysql_query("SELECT product_name FROM shop_products WHERE product_id='$productid'") or die("Error Side basket ".mysql_error());
$basket_product=mysql_fetch_array($b_product_res);
$content .= $basket_product['product_name'].' X '.$basket_items['product_qty']."\n";
}
$content .= '<br />       
<a href="order.php" title="Order Now">Order Now</a><br />'
;
$content .= '</div>';
include(
'../themes/'.THEME.'/template.inc.php');
?>
Here is the shopping basket (basket.php)
PHP Code:
<?php
require('../includes/includes.php');
$pgtitle 'Shop';
$extraheader '
<link rel="stylesheet" href="/js/lightbox/css/lightbox.css" type="text/css" media="screen" />
<script src="/js/lightbox/js/prototype.js" type="text/javascript"></script>
<script src="/js/lightbox/js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="/js/lightbox/js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
.product { float:left; width:520px; border:1px solid #C2DFEE; padding:5px; margin:2px 0 0 0;}
.product img {border:0; padding:0; margin:0 0 0 20px; float:right}
.product_details {clear:both; width:500px; padding:0; margin:0;}
.product_details ul { list-style:none; padding:0; margin:0;}
.product_details li {float:left; padding:0; margin:0 10px 0 0; text-align:center;}
</style>'
;
$sessid session_id();
$datetime date('Y-m-d H:i:s');
$b_res mysql_query("SELECT * FROM shop_baskets WHERE sid='$sessid'") or die("ERROR" .mysql_error());
$content .= '<div style="">';
if(isset(
$_POST['remove']))
{
$basket_id $_POST['basket_id'];
mysql_query("DELETE FROM shop_baskets WHERE basket_id='$basket_id'") or die(mysql_error());
header('Location: '.$_SERVER['PHP_SELF']);
}
if(isset(
$_POST['change']))
{
$basket_id $_POST['basket_id'];
$newqty $_POST['qty'];
mysql_query("UPDATE shop_baskets SET product_qty='$newqty' WHERE basket_id='$basket_id'") or die(mysql_error());
header('Location: '.$_SERVER['PHP_SELF']);
}
$content .= '<table>';
$content .= '<tr style="background:gray; color:#fff">
<td>Item Name</td>
<td>Quantity</td>
<td>Price</td>
<td>Total</td>
</tr>'
;
while(
$mybasket_info=mysql_fetch_array($b_res))
{
$product_res=mysql_query("SELECT * FROM shop_products WHERE product_id='".$mybasket_info['product_id']."'") or die(mysql_error());
$product_info=mysql_fetch_array($product_res);
$p_total $product_info['product_price'] * $mybasket_info['product_qty'];
$content .= '<form method="post" action="">';
$content .= '<tr><td>'."\n";
$content .= $product_info['product_name']."\n";
$content .= '</td><td>'."\n";
$content .= '<input type="text" size="3" name="qty" value="'.$mybasket_info['product_qty'].'" />'."\n";
$content .= '</td><td>&pound;'."\n";
$content .= $product_info['product_price']."\n";
$content .= '</td><td>&pound;'."\n";
$content .= $p_total."\n";
$content .= '</td><td>'."\n";
$content .='
<input type="hidden" name="basket_id" value="'
.$mybasket_info['basket_id'].'" />
<input type="submit" name="change" value="Change" />
<input type="submit" name="remove" value="Remove" />
</form>'
."\n";
$content .= '</td></tr>'."\n";
}
$content .= '</table>
<span style=""><a href="order.php" title="Order Now">Order Now</a></span>
</div>'
;
include(
'../themes/'.THEME.'/template.inc.php');
?>
and finall here is order.php which uses switch() to go through the stages of ordering... and confirming and evenually contacting me/someone via email with the order.

PHP Code:
<?php
require('../includes/includes.php');
$pgtitle 'Shop';
$extraheader '
<link rel="stylesheet" href="/js/lightbox/css/lightbox.css" type="text/css" media="screen" />
<script src="/js/lightbox/js/prototype.js" type="text/javascript"></script>
<script src="/js/lightbox/js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="/js/lightbox/js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
.product { float:left; width:520px; border:1px solid #C2DFEE; padding:5px; margin:2px 0 0 0;}
.product img {border:0; padding:0; margin:0 0 0 20px; float:right}
.product_details {clear:both; width:500px; padding:0; margin:0;}
.product_details ul { list-style:none; padding:0; margin:0;}
.product_details li {float:left; padding:0; margin:0 10px 0 0; text-align:center;}
</style>'
;
$sessid session_id();
switch(
$_GET['step'])
{
case 
'1':
$content .= '<div style="text-align:center">
<h2>Select Payment Method</h2>
<p>At the present time Calm can only accept payments by check, or cash.</p>
<p>DO NOT send cash through the post.</p>
<a href="/shop/order.php?step=2&type=check">Check</a>
<a href="/shop/order.php?step=2&type=cash">Cash</a>
</div>'
;
break;
case 
'2':
$type $_GET['type'];
$content .= '<div style="text-align:center;">
</div>'
;
break;
case 
'3':
$type $_GET['type'];
if(isset(
$_POST['submit']))
{
$cust_title     $_POST['title'];
$cust_firstname $_POST['firstname'];
$cust_lastname  $_POST['lastname'];
$cust_email     $_POST['email'];
$cust_addr1     $_POST['addr1'];
$cust_addr2     $_POST['addr2'];
$cust_city      $_POST['city'];
$cust_county    $_POST['county'];
$cust_country   $_POST['country'];
$cust_zipcode   $_POST['zipcode'];
$cust_phone     $_POST['phone'];
$sessionid      $_POST['sessid'];
$payment_type   $_POST['payment_type'];
$errors 0;
  
// If there are errors highlight the fields.
  
$extraheader .= '<style>
  .error  
  {
  color: #781351;
  background: #fee3ad;
  border: 1px solid #781351
  }
  </style>'
;
  
$content .= '<p>Enetr Info</p>';
$content .= '<form method="post" action="/shop/order.php?step=3">';
$content .= '<label for="title" class="order">Title:</label>';
$content .= '<strong>'.$_POST['title'].'</strong>
<br />'
;
$content .= '<label for="firstname" class="order">First Name: </label>';
$content .= '<input type="text" name="firstname" size="20" value="'.$_POST['firstname'].'" /><br />';
// LAST NAEM
$content .= '<label for="lastname" class="order">lastname: </label>';
$content .= '<input type="text" name="lastname" size="20" value="'.$_POST['lastname'].'" ';
if(
strlen($_POST['lastname']) < || strlen($_POST['lastname']) > 25)
{
$content .= 'class="error"';
$errors++;
}
$content .=' /><br />';
// EMAIL
$content .= '<label for="email" class="order">Email:</label>';
$content .= '<input type="text" name="email" size="30" value="'.$_POST['email'].'"';
if(
email_valid($_POST['email']) == FALSE)
{
$content .= ' class="error"';
$errors++;
}
$content .= ' /><br />';
// ADDR 1
$content .= '<label for="addr1" class="order">Address 1:</label>';
$content .= '<input type="text" name="addr1" size="30"  value="'.$_POST['addr1'].'"/><br />';
// ADDR 2
$content .= '<label for="addr2" class="order">Address 2:</label>';
$content .= '<input type="text" name="addr2" size="30" value="'.$_POST['addr2'].'" /><br />';
// TOWN / CITY
$content .= '<label for="city" class="order">Town/City:</label>';
$content .= '<input type="text" name="city" size="30" value="'.$_POST['city'].'" /><br />';
// County
$content .= '<label for="county" class="order">County:</label>';
$content .= '<input type="text" name="county" size="30" value="'.$_POST['county'].'" /><br />';
//Country
$content .= '<label for="country" class="order">Country:</label>';
$content .= '<strong>'.$_POST['country'].'</strong>
<br />'
;
$content .= '<label for="zipcode" class="order">Zipcode:</label>';
$content .= '<input type="text" name="zipcode" size="9" value="'.$_POST['zipcode'].'" /><br />';
$content .= '<label for="phone" class="order">Phone:</label>';
$content .= '<input type="text" name="phone" size="15" value="'.$_POST['phone'].'" /><br />';
$content .= '<input type="hidden" name="payment_type" value="'.$_GET['type'].'" />';
$content .= '<input type="hidden" name="sessid" value="'.$sessid.'" />';
 
  if(
$errors == 0)
  {
  
$content .= '</form>';  
  
$content .= '<p>Infomation validated and no errors found.</p>
               <form action="/shop/order.php?step=4" method="post">
      <input type="hidden" name="title" value="'
.$_POST['title'].'" />
      <input type="hidden" name="firstname" value="'
.$_POST['firstname'].'" />
      <input type="hidden" name="lastname" value="'
.$_POST['lastname'].'" />
      <input type="hidden" name="email" value="'
.$_POST['email'].'" />
      <input type="hidden" name="addr1" value="'
.$_POST['addr1'].'" />
      <input type="hidden" name="addr2" value="'
.$_POST['addr2'].'" />
      <input type="hidden" name="city" value="'
.$_POST['city'].'" />
      <input type="hidden" name="county" value="'
.$_POST['county'].'" />
      <input type="hidden" name="country" value="'
.$_POST['country'].'" />
      <input type="hidden" name="zipcode" value="'
.$_POST['zipcode'].'" />
      <input type="hidden" name="phone" value="'
.$_POST['phone'].'" />
      <input type="hidden" name="sessid" value="'
.$_POST['sessid'].'" />
      <input type="hidden" name="payment_type" value="'
.$_POST['payment_type'].'" />
      <input type="submit" name="submit" value="Continue -" />
      </form>'
;
  }
  else {
  
$content .= '<input type="submit" name="submit" value="Continue" />';
  }
}
else {
$content .= '<p>Please enter delivery and contact infomation below</p>';
$content .= '<form method="post" action="/shop/order.php?step=3">';
$content .= '<label for="title" class="order">Title:</label>';
$content .= '<select name="title">
<option value="mr">Mr</option>
<option value="mrs">Mrs</option>
<option value="miss">Miss</option>
<option value="ms">Ms</option>
<option value="dr">Dr</option>
</select>
<br />'
;
$content .= '<label for="firstname" class="order">First Name: </label>';
$content .= '<input type="text" name="firstname" size="20" /><br />';
$content .= '<label for="lastname" class="order">lastname: </label>';
$content .= '<input type="text" name="lastname" size="20" /><br />';
$content .= '<label for="email" class="order">Email:</label>';
$content .= '<input type="text" name="email" size="30" /><br />';
$content .= '<label for="addr1" class="order">Address 1:</label>';
$content .= '<input type="text" name="addr1" size="30" /><br />';
$content .= '<label for="addr2" class="order">Address 2:</label>';
$content .= '<input type="text" name="addr2" size="30" /><br />';
$content .= '<label for="city" class="order">Town/City:</label>';
$content .= '<input type="text" name="city" size="30" /><br />';
$content .= '<label for="county" class="order">County:</label>';
$content .= '<input type="text" name="county" size="30" /><br />';
$content .= '<label for="country" class="order">Country:</label>';
$content .= '<select name="country" class="">
<option value="UK" selected="selected">United Kingdom</option>
<option value="US">United States</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan Republic</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BB">Barbados</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia and Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BR">Brazil</option>
<option value="VG">British Virgin Islands</option>
<option value="BN">Brunei</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="C2">China Worldwide</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="HR">Croatia</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="CD">Democratic Republic of the Congo</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="EC">Ecuador</option>
<option value="SV">El Salvador</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FM">Federated States of Micronesia</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="GA">Gabon Republic</option>
<option value="GM">Gambia</option>
<option value="DE">Germany</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea Bissau</option>
<option value="GY">Guyana</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Laos</option>
<option value="LV">Latvia</option>
<option value="LS">Lesotho</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn Islands</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="QA">Qatar</option>
<option value="CG">Republic of the Congo</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russia</option>
<option value="RW">Rwanda</option>
<option value="VC">Saint Vincent and the Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">São Tomé and Príncipe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="KR">South Korea</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SH">St. Helena</option>
<option value="KN">St. Kitts and Nevis</option>
<option value="LC">St. Lucia</option>
<option value="PM">St. Pierre and Miquelon</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard and Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="UY">Uruguay</option>
<option value="VU">Vanuatu</option>
<option value="VA">Vatican City State</option>
<option value="VE">Venezuela</option>
<option value="VN">Vietnam</option>
<option value="WF">Wallis and Futuna Islands</option>
<option value="YE">Yemen</option>
<option value="ZM">Zambia</option>
</select>
<br />'
;
$content .= '<label for="zipcode" class="order">Zipcode:</label>';
$content .= '<input type="text" name="zipcode" size="9" /><br />';
$content .= '<label for="phone" class="order">Phone:</label>';
$content .= '<input type="text" name="phone" size="15" /><br />';
$content .= '<input type="hidden" name="payment_type" value="'.$_GET['type'].'" />';
$content .= '<input type="hidden" name="sessid" value="'.$sessid.'" />';
$content .= '<input type="submit" name="submit" value="Continue" />';
$content .= '</form>';
}
break;
case 
'4':
$cust_title     $_POST['title'];
$cust_firstname $_POST['firstname'];
$cust_lastname  $_POST['lastname'];
$cust_email     $_POST['email'];
$cust_addr1     $_POST['addr1'];
$cust_addr2     $_POST['addr2'];
$cust_city      $_POST['city'];
$cust_county    $_POST['county'];
$cust_country   $_POST['country'];
$cust_zipcode   $_POST['zipcode'];
$cust_phone     $_POST['phone'];
$sessionid      $_POST['sessid'];
$payment_type   $_POST['payment_type'];
$cust_b_res mysql_query("SELECT * FROM shop_baskets WHERE sid='$sessionid'");
$cust_basket1=mysql_fetch_array($cust_b_res);
mysql_query("INSERT INTO shop_cust SET cust_title='$cust_title',cust_firstname='$cust_firstname',cust_lastame='$cust_lastame',cust_email='$cust_email',
cust_addr1='
$cust_addr1',cust_addr2='$cust_addr2',cust_city='$cust_city',cust_county='$cust_county',cust_country='$cust_country',
cust_zipcode='
$cust_zipcode',cust_phone='$cust_phone'");
$cust_res=mysql_query("SELECT * FROM shop_cust WHERE cust_phone='$cust_phone'");
$cust=mysql_fetch_array($cust_res);
mysql_query("UPDATE shop_baskets SET cust_id='{$cust['cust_id']}' WHERE sid='$sessionid'");
$to 'admin@dansgalaxy.co.uk';
$subject '[CALM] ORDER INFOMATION';
$body .= "Hello,\n";
$body .= "$cust_title $cust_firstname $cust_lastname has made a order.\n";
$body .= "\n";
$body .= "\n";
$body .= "Basket Items:\n";
$body .= "\n";
$sub_total 0;
while(
$cust_basket=mysql_fetch_array($cust_b_res))
{
$product_res mysql_query("SELECT * FROM shop_products WHERE product_id='{$cust_basket['product_id']}'");
$product_info mysql_fetch_array($product_res);
$body .= "{$product_info['product_name']} X {$cust_basket['product_qty']} @ {$product_info['product_price']} each.\n";
$p_total .= $product_info['product_price'] * $cust_basket['product_qty'];
$sub_total $sub_total $p_total;
}
$total $sub_total 0.5;
$body .= "Total + standard p+p: $total \n";
$body .= "\n";
$body .= "Delivery Address:\n";
$body .= "\n";
$body .= "Addr 1: $cust_addr1 \n";
$body .= "Addr 2: $cust_addr2 \n";
$body .= "County: $cust_county\n";
$body .= "country: $cust_country \n";
$body .= "Postcode: $cust_zipcode\n";
$body .= "\n";
$body .= "Tel: $cust_phone\n";
$body .= "Email: $cust_email\n";
$body .= "\n";
$body .= "\n";
$body .= "Please confirm the actual Postage and Packing charges and email/phone customer.\n";
$body .= "Once payment has been recieved, Ship\n";
mail($to$subject$body$header);
break;
default:
$content .= '<table>';
$content .= '<tr style="background:gray; color:#fff">
<td>Item Name</td>
<td>Quantity</td>
<td>Price</td>
<td>Total</td>
</tr>'
;
$sub_total 0;
$b_res mysql_query("SELECT * FROM shop_baskets WHERE sid='$sessid'") or die("ERROR" .mysql_error());
while(
$mybasket_info=mysql_fetch_array($b_res))
{
$product_res=mysql_query("SELECT * FROM shop_products WHERE product_id='".$mybasket_info['product_id']."'") or die(mysql_error());
$product_info=mysql_fetch_array($product_res);
$p_total $product_info['product_price'] * $mybasket_info['product_qty'];
$content .= '<tr><td>'."\n";
$content .= $product_info['product_name']."\n";
$content .= '</td><td>'."\n";
$content .= $mybasket_info['product_qty']."\n";
$content .= '</td><td>&pound;'."\n";
$content .= $product_info['product_price']."\n";
$content .= '</td><td>&pound;'."\n";
$content .= $p_total."\n";
$content .= '</td><td>'."\n";
$content .= '</td></tr>'."\n";
$sub_total $sub_total $p_total;
}
$content .= '</table>';
$content .= 'Sub Total: &pound;'.$sub_total.'<br />';
$content .= 'P&P: &pound;0.50 * <br />';
$total $sub_total 0.5;
$content .= 'Total: &pound;'.$total// Fix so works out proper postage through set of reates. not needed unless more products added.
$content .= '<br /><br />
<a href="/shop/order.php?step=1" title="Confirm order and continue">Confirm Order</a>   
<a href="/shop/basket.php" title="Edit Order">Edit</a><br />
<br />
<p style="font-style:italic">* Please note Postage and Packing is subject to change depending on the quantity, size and country of delivery address, you will be notified either via email or phone on the final charge of P&amp;P</p>'
;
break;
}

include(
'../themes/'.THEME.'/template.inc.php');
?>
i know this post will be huge, i am trying to add some validation to the form on order which u can probs see the beginings of above

any improvments welcome.

Also if anyone willing to help via msn much appriciated
dansgalaxy@hotmail.co.uk

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Need PHPer to help fix/dev Small shop script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35631 seconds with 12 queries