Jump to content

Save Users Cart Info


Watertech

Recommended Posts

Hello,

  I have been working on an add on to my current shopping cart that will save the customers order and so on. It works and all is fine if I just stopped there. This is the code for the working scrpit(1st Working): When loaded the customer is required to log in before the cart and buttons will appear. I am wanting to to use the save order and clear order buttons on a different page that has its own log in script (2nd Working). However, as you gurus probably already see, I cannot simply paste the 1st working scrpit inside the 2nd because they both require a log in.

Where is your question man???

How do I change 1st working so that it will work in 2nd. I do not want to use both only replace the first log in with the second log in and have the functionality of the buttons. I have tried changing 1st working session variables to match 2nd working, however it will not create the session.

 

If someone is looking for a free shopping with customer log in

visit, NOP Design

Here is log in add on.

 

Stand alone log in can be found here. I have created a setup.php that will create the data base automatically. Set Up

 

Thanks for any input.......

Regards,

  Howard

 

1st Working>>>>>

<?php
if(isset($_REQUEST['clear'])){
$query="UPDATE cart SET id='', qty='', price='', name='', shipping='', addit='' WHERE email LIKE \"%$email%\"";
$results = mysql_query($query) or die("Error deleting cart contents");
}
if(isset($_SESSION['last_name'])){
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email_address'];
if(isset($_REQUEST['id'])){
$id = $_REQUEST['id'];}	
if(isset($_REQUEST['qty'])){
$qty = $_REQUEST['qty'];}	
if(isset($_REQUEST['price'])){
$price = $_REQUEST['price'];}	
if(isset($_REQUEST['name'])){
$name = $_REQUEST['name'];}	
if(isset($_REQUEST['shipping'])){
$shipping = $_REQUEST['shipping'];}	
if(isset($_REQUEST['addit'])){
$addit = $_REQUEST['addit'];}	
if(isset($id)){
$sql = mysql_query("UPDATE users SET id='$id', qty='$qty', price='$price', name='$name', shipping='$shipping', addit='$addit' WHERE last_name='$last_name' AND email_address='$email'"); 
}
?>
     <center><h2>Your Shopping Cart </h2>
  <br><br>
<form name="form" action="checkout.php" method="get" onsubmit="return ValidateCart(this)">
     <script language="javascript" type="text/javascript">
      ManageCart();      	  
     </script>	  
<BR><BR>
<input type="button" value="Continue Shopping" onclick="javascript:history.back()">
<input type="button" value="Refresh Cart" onclick="history.go()">
<input name="Empty" type="button" value="  Empty Cart  " onClick="SetCookie ('NumberOrdered', 0, null, '/');document.location=('managecart.html')"> 
<input type="submit" value="Checkout"><br><br>
<input type="button" value="Save Order" onClick='save(this)'>
<input type="button" name="clear=0" value="Clear Saved Orders" onClick='refresh(this.name)'>
</form>
</center>
<?php
include 'footer.php';
}
else{
echo "You must be logged in to access this part of our store";
echo "<br><br>";
echo "<a href=\"$my_site_path/login_form.html\">Click Here to Login Now</a>";
}
?>       

 

(2nd Working)

<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>




<table>
<tr><td>


<?
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
  echo "<h1>Logged In</h1>";
  echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
      ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>]   "
      ."[<a href=\"useredit.php\">Edit Account</a>]   ";
  if($session->isAdmin()){
     echo "[<a href=\"admin/admin.php\">Admin Center</a>]   ";
  }
  echo "[<a href=\"process.php\">Logout</a>]";
  
}

else{
?>

<h1>Login</h1>
<?
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
  echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>

 

 

</td></tr>

</table>

 

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/100243-save-users-cart-info/
Share on other sites

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.