PHP - Can't Delete Cookies....
Code: [Select]
<?php session_start(); setcookie("user_id", "", time()-3600, "/", "www.mystagingsite1.net"); setcookie("territory", "", time()-3600, "/", "www.mystagingsite1.net"); setcookie("membership_level", "", time()-3600, "/", "www.mystagingsite1.net"); session_destroy(); header("Location: gateway.php"); ?> I am setting them using set cookie like: Code: [Select] <?php setcookie("user_id", $row['user_id'], time()+3600, "/", "www.mystagingsite1.net"); setcookie("territory", $row['territory'], time()+3600, "/", "www.mystagingsite1.net"); setcookie("membership_level", $row['membership_level'], time()+3600, "/", "www.mystagingsite1.net"); ?> This is not deleting cookies. It should be. If I do this and it redirects me then I revisit the homepage, I am still logged in even after doing this. I have tried doing this in about 20 different ways and these stupid sessions won't die. I even tried unsetting them manually as well, nothing is working. Advice? Similar Tutorialshya, ive given a link from my index page to a pgave i call logout.php in that page i have the following code: Code: [Select] <?php if (isset($_COOKIE['User_Id'])){ setcookie('User_Id', "" ,time()-3600); setcookie('UserName', "" ,time()-3600); echo "cookies has been deleted"; } else {echo 'you are not loged in' ;} ?> i get the 'echo "cookies has been deleted";' msg but the cookies are not dellted, any ides ? Ok, a bit of background. I am working on a modified version of this script - http://www.evolt.org/node/60265 Now if I go by using the Log out script, it deletes the cookies no problem, here is the log out script <? session_start(); include("./inc/connect.php"); include("../global/login.php"); /** * Delete cookies - the time must be in the past, * so just negate what you added when creating the * cookie. */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ setcookie("cookname", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/"); } if(!$logged_in){ echo "<h1>Error!</h1>\n"; echo "You are not currently logged in, logout failed. Back to <a href=\"index.php\">main</a>"; } else{ /* Kill session variables */ unset($_SESSION['username']); unset($_SESSION['password']); $_SESSION = array(); // reset session array session_destroy(); // destroy session. echo "<h1>Logged Out</h1>\n"; echo "You have successfully <b>logged out</b>. Back to <a href=\"index.php\">main</a>"; } ?> Now the includes at the top of the log out page are already loaded from the index which pulls the following code when a form is filled out: $password = md5(stripslashes($_REQUEST['npass'])); $update = "UPDATE users SET password = '$password' WHERE storeid = '$store' && username = '$username' "; $which = $handle_db1; $rsUpdate = mysql_query($update,$which); if ($rsUpdate) { echo "<h2>Password Update successful</h2>"; } mysql_close(); if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ setcookie("cookname", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/"); } /* Kill session variables */ unset($_SESSION['username']); unset($_SESSION['password']); $_SESSION = array(); // reset session array session_destroy(); // destroy session. echo "<Strong>Logged Out due to Password Change</strong><br>\n"; echo "Please <a href=\"index.php\">login</a> with the new password"; The parts are copied directly from the Log out page which is why I am trying to figure out why its not allowing me to remove the cookies cookname and cookpass. I am at a lose, no errors come up, just the cookies still exist after I change the password and go to log back in. The only differences I see are 1. the if(!$logged_in) request is not in my moded code, and 2. neither is session_start() (which doesn;t matter cuz I did just try it to no avail) I don't see any other issue with this. Hi I have made this simple login page by setcookies function and I want now to make a logout button. Here the codeĀ <?php /* PHP Form Login Remember Functionality with Cookies */ if(!empty($_POST["remember"])) { setcookie ("username",$_POST["username"],time()+ 3600); setcookie ("password",$_POST["password"],time()+ 3600); setcookie ("color",$_POST["color"],time()+ 3600); //3600 = 1 hour //86400 = 1 day //(8640*30) = 1 month echo "Cookies Set Successfuly"; } else { setcookie("username",""); setcookie("password",""); setcookie("color",""); echo "Cookies Not Set"; } ?> <form action="Cookies.php" method="post" style="border: 2px dotted blue; text-align:center; width: 400px;"> <p>Welcome <?php echo ( !empty($_POST ['username']) ) ? $_POST ['username'] : 'USER'; ?> </p> <p>Username: <input name="username" type="text" value="<?php if(isset($_COOKIE["username"])) { echo $_COOKIE["username"],( !empty($_POST ['username']) ) ? $_POST ['username'] : '';} ?>" > </p> <p>Password: <input name="password" type="password" value=" <?php if(isset($_COOKIE["password"])) { echo $_COOKIE["password"]; } ?>" > </p> <p>Choose Your Favorite Color: <input name="color" type="color" value="<?php if(isset($_COOKIE["color"])) { echo $_COOKIE["color"]; } ?>"> </p> <p><input type="checkbox" name="remember" /> Remember me</p> <p><input type="submit" value="Login"></p> </form> Any idea ?? Hi all. Here is my scripts which allow user to check multiple rows of data and delete it , but it require select data and click for twice to delete the rows , what should be the error? Code: [Select] <form name="frmSearch" method="post" action="insert-add.php"> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> </form> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if (isset($_POST['delete']) && isset($_POST['checkbox'])) // from button name="delete" { $checkbox = ($_POST['checkbox']); //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql) or trigger_error(mysql_error());;; } if($result2) { $fgmembersite->GetSelfScript(); } else { echo "Error: ".mysql_error(); } } echo "</form>"; Thanks for every reply. <body> <?php include 'sql.php'; $query = "SELECT * FROM validation"; $result = mysqli_query($con , $query); $rows = mysqli_fetch_assoc($result) ; $totals = mysqli_num_rows($result) ; ?> <div id="css"> <form > <table width="80%" border="0" cellpadding="2" cellspacing="2" > <caption><h2>Personal Details of Customers</h2></caption> <tr class="white"> <td bgcolor="#330033"> </td> <td bgcolor="#330033"> Id Number </td> <td bgcolor="#330033"> Full Name </td> <td bgcolor="#330033"> Email Address </td> <td bgcolor="#330033"> Website </td> <td bgcolor="#330033"> Comment </td> <td bgcolor="#330033"> Time </td> </tr> <?php while($rows=mysqli_fetch_assoc($result) { <tr> <input type="raido" name="ID" value="<?php echo $rows['ID']; ?>" /> <td bgcolor="#FFFFCC"><?php echo $rows['ID'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Name'];?> </td> <td bgcolor="#FFFFCC"><?php echo $rows['Email'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Website'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Comment'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Time'];?></td> <td> </td> <td> <a href="delete.php? ID= "$rows[ID]" /"> <input type="submit" name="del" value="Delete" /> </a> <input type="button" name= "edit" value="Edit" /> </td> </tr> }?> </table> </form> </div> </body> Hi,
I wish to find out is there any possible that I can delete some data inside my php website but inside my sql database, the record will still at there?
Thank you.
I'm trying to set it so that it will delete an entire populated directory based upon a value in the database then after finishing that to go back and delete that row in the database. my current code is Code: [Select] <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="delprod.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product To Remove:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select name=\"which\">"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['id'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and the delete script Code: [Select] <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT id FROM Products WHERE id=$_POST['which']"); $row = mysql_fetch_array($result) chdir('assets'); chdir('images'); $mydir = $row . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($_POST['which'] . '/' . $entry); } } rmdir($mydir); $result = mysql_query("DELETE * FROM Producs WHERE id=$_POST['which']"); ?> Thank you in advance for all your help. any easier ways of approaching this will be welcome as well When a user logs in it sets a cookie with their user id and sets the time they choose(either a session cookie or a cookie lasting one year for users who wish to stay logged in). when they select to stay logged in forever and close the browser the next time they open it, it tells them they arent logged in. however when they go to a new page they appear to be logged in. What i dont understand is why they have to go to a new page for it to say they are logged in. Here is the code which runs everytime the site is load if (isset($_COOKIE['uid'])) { $user->setup($_COOKIE['uid']); } user setup basically selects their info from the database and sets their username and other info to variables. Anyone know a better way to do this? I'm trying to write a script that allows the user to select their personal settings for the site. They can pick the color of their background, link color, link hover color and the header color. the first file is supposed to use the defaults, blue for the links, orange for the link hover color red for the background and blue for the header. the second file is supposed to configure the cookie variables to store the values entered by the user and the third file i'm supposed to modify the internal stylesheet to utilize the values stored in the session variables. I tried to set each of the values in file two but i think i messed it up. I dont know how to modify the stylesheet to accept and change to the values of the cookies...Please help here are the files file1.php Code: [Select] <?php //Handle the form if it has been submitted: if (isset($_POST['background_color'], $_POST['link_color'], $_POST['link_hover_color'], $_POST['header_color'])){ //send the cookies: setcookie('background_color', $_POST['background_color'], time()+10000000); setcookie('link_color', $_POST['link_color'], time()+10000000); setcookie('link_hover_color', $_POST['link_hover_color'], time()+10000000); setcookie('header_color', $_POST['header_color'], time()=10000000); //Message to be printed later: $msg = '<p>Your settings have been entered! Click <a href="file2.php">here</a> to see them in action.</p>'; } ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File1</title> <style type="text/css"> <!-- These are the styles the session (if it exists) should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <?php //if the cookies were sent print a message if (isset($msg)){ print $msg; } ?> <div><p>Please complete this form to configure the appearance of this website:</p> <form action="File2.php" method="post"> <select name="background_color"> <option value="">Background Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_color"> <option value="">Link Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_hover_color"> <option value="">Link Hover Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="header_color"> <option value="">Header Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <input type="submit" name="submit" value="Configure!" /> </form> </div> </body> </html> file2.php Code: [Select] <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File2</title> </head> <body> <div> <?php include('file1.php'); //check for a background color if (isset($_COOKIE['background_color'])){ print "\body: #" . htmlentities($_COOKIE['background_color']) . ";\n"; }else{ print "\body: #c00"; } //check for a link_color if (isset($_COOKIE['link_color'])){ print "\a:link: #" . htmlentities($_COOKIE['link_color']) . ";\n"; }else{ print "\a:link: #00f"; } //check for a link_hover color: if (isset($_COOKIE['link_hover_color'])){ print "a\:hover: #" . htmlentities($_COOKIE['link_hover_color']) . ";\n"; } //Check for a header color if (isset($_COOKIE['header_color'])){ print "\h1: #" . htmlentities($_COOKIE['header_color']). ";\n"; } ?> Your settings have been updated. <a href="File3.php">Click here</a> to continue. <br /><br /> </div> </body> </html> file3.php Code: [Select] <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File3</title> <style type="text/css"> <!-- These are the styles the session should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <div> <h1>Welcome to YOUR pretty website</h1> <a href = "File1.php">Click here</a> to go back and start over!</a> </div> </body> </html> I'm pretty sure i did in file2 what i was supposed to do in file3 im totally confused This is prob a stupid question.. but i've always wondered..
When deleting a cookie why do we use
why do we use:
setcookie($name, '', time() - 3600, "/", "", 0);
when this works just fine:
setcookie($name, '', 0, "/", "", 0);
isn't the time() just a waste of space?
I ask this because everywhere i look i see:
setcookie($name, '', time() -3600 , "/", "", 0);
i was trying to make a new login script and wanted to make point system which i can add points manually to member so i made a new column and named it userpoint i tried many many codes First i used
$_SESSION['userName'] = $username; echo "Welcome ".$_SESSION['userName']."!"; $_SESSION['userpoint'] = $userpoint; echo "you got".$_SESSION['userpoint']."!";the page showed username but didn`t show the points ! i tried then i figured out cookies if(isset($_COOKIE['ID_my_site'])) { setcookie( "userpoint"); $username = $_COOKIE['ID_my_site']; $userpoint = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check)) {this time the page shows both of usernames without mentioning the points ! i changed $userpoint = $_COOKIE['ID_my_site'];to $userpoint = $_COOKIE['Key_my_site']; and it showed the hashed password i want to set a new $_COOKIE so i can get members point to member area is that possible ? the script is still missing secure and salt and the security stuff i`ll add them later i just want to know if is that possible Edited by Ahmedamer, 03 September 2014 - 09:39 PM. i'm trying to set a cookie value to a result from a query, but its not working. all of the other cookies are being set, except for one. any ideas why? <?php //Checks if there is a login cookie if(isset($_COOKIE['ID_forum'])) //if there is, it logs you in and directs you to the members page { $username = $_COOKIE['ID_forum']; $pass = $_COOKIE['Key_forum']; $user_level = $_COOKIE['Forum_level']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: index.php"); } } } if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die(' <h2> You did not fill in all of the fields</h2> <p<a href="login.php">Return to login page</a> '); } // checks it against the database $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die(' <h2> That user does not exist in our database.<br/> </h2> <p<a href="login.php">Return to login page</a> '); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = mysql_real_escape_string($_POST['pass']); $info['password'] = mysql_real_escape_string($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die(' <h2> Incorrect password, please try again</h2> <p<a href="login.php">Return to login page</a> '); } else { $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['user_level'] = mysql_real_escape_string($_POST['user_level']); $hour = time() + 3600; setcookie(ID_forum, $_POST['username'], $hour); setcookie(Key_forum, $_POST['pass'], $hour); setcookie(Forum_level, $_POST['user_level'], $hour); //this cookie is not being set setcookie(test, 'test cookie', $hour); // testing that cookie is being set - this works header("Location: index.php"); $query2 = mysql_query("SELECT * FROM users WHERE username = ".$_POST['username'])or die(mysql_error()); setcookie(Level_forum, $query2['user_level'], $hour); } } } else { // if they are not logged in ?> //form code is here. i have not included it to save space <?php } ?> Thanks Okay im having a problem with cookies so if anyone can help i would be grateful. When you login you can choose how long to stay in for. For testing purposes the choices a Forever 1 Hour 1 Day Never Based on your choice i am setting the cookie expiration as follows: if ($_POST['remember_me'] == '1') { setcookie('remember', time() + 99999999999999); } elseif ($_POST['remember_me'] == '3600') { setcookie('remember', time() + 3600); } elseif ($_POST['remember_me'] == '84600') { setcookie('remember', time() + 84600); } elseif ($_POST['remember_me'] == '0') { setcookie('remember'); } echo $_COOKIE['remember']; } Then for testing I am echoing the cookie at the head of the document: echo "Cookie: " . @$_COOKIE['remember']; The problem is that when the browser is closed the cookie is gone. Only the last option "never" is set as a session cookie which means the others should stay active even when the browser is closed shouldnt they? Anything i have missed here? This has been driving me crazy for hours! I am trying to set a cookie: setcookie("username", $_POST['user']); And for a while it wasn't working, then it started randomly working. Now, when I try to use if(isset($_COOKIE['username'])) PHP is saying the cookie does not exist. PLEASE help! Thanks. Hi guys, I am having a sticky problem with Cookies. Basically, I've had to change the settings of my CMS which has resulted in me now having the same cookie names for the cookie domains .domain.com and www.domain.com. I know I can just clear my cookies and the problem will be sorted, but it's not feasible for me to expect users of my site to clear their cookies. So my question is this. How can I delete the cookies created using www.domain.com with PHP? Everytime I set the expiry date of the cookies, it only applies it to those on .domain.com. Any help would be gratefully appreciated!! Dear all, i need help so badly...urgent i have customize a simple e-comm site (from www.phpwebcommerce.com tutorial), when user go checkout page(cart.php) it will show product item, quantity, sub-total , shipping, state and total price. Original from the tutorial using php do calculation but shipping cost is flat rate, i need to calculate shipping cost by state & quantity so that i use JavaScript do the calculation. my shopping cart process : 1. user checkout - go to cart.php (user can update qunatity and select state from this page then update cart) this page is working fine... 2. user enter info - user enter payment and shipping address 3. user continue checkout - go to checkoutconfirmation.php (my problem appear here, the information like quantity, sub-total, shipping cost & total from cart.php won't update here) I'm trying not do confuse myself & do it the eaiser way by using PHP cookies to send the javascript value tocheckoutconfirmation.php but i'm not sure how it work....i'm new to php and javascript, any help will appeciated ! Thank you in advanced !! cart.php Code: [Select] <?php require_once 'library/config.php'; require_once 'library/cart-functions.php'; $action = (isset($_GET['action']) && $_GET['action'] != '') ? $_GET['action'] : 'view'; switch ($action) { case 'add' : addToCart(); break; case 'update' : updateCart(); break; case 'delete' : deleteFromCart(); break; case 'view' : } $cartContent = getCartContent(); $numItem = count($cartContent); $pageTitle = 'Shopping Cart'; require_once 'include/header.php'; // show the error message ( if we have any ) displayError(); if ($numItem > 0 ) { ?> <head> <script type="text/javascript"> <!-- Begin function doMath() { var one = eval(document.getElementById('txtQty[]').value) //one = quantity //alert(one); var price = 0; var state = document.frmCart.state.value; ///////var pd_price = 72; ////////////// var unitPrice = document.getElementById('pd_price').innerText.substring(3); //alert(unitPrice); //alert(one); if(state == "east"){ if (one == 1){ price = 6; } else if (one == 2){ price = 8; } else if (one == 3){ price = 10; } else if (one == 4){ price = 12; } else if (one == 5){ price = 12.50; } else if (one == 6){ price = 13; } else if (one == 7){ price = 14; } else if (one == 8){ price = 0; } } else if(state == "west"){ if (one == 1){ price = 9.30; } if (one == 2){ price = 12; } if (one == 3){ price = 17.25; } if (one == 4){ price = 20; } if (one == 5){ price = 21; } if (one == 6){ price = 22; } if (one == 7){ price = 23.45; } if (one == 8){ price = 0; } } document.getElementById('subtotal').innerText = "MYR" + unitPrice * one; //document.frmCart.amount.innerText=price; document.getElementById('amount').innerText = price; ///amount = shipping //alert("asdf"); var test = document.getElementById('subtotal').innerText; // = one*pd_price; // //alert(test); //alert(one); test = parseInt(test.substring(3)) * one; //alert(test); //document.getElementById('subtotal').innerText = test; //alert(test); //alert("A" + price); //alert(parseInt(test)); //alert(one); document.getElementById('total').innerText = price + unitPrice * one; //total = shipping + subtotal test = "MYR" + test; document.getElementById('ct_qty').innerText = document.getElementById('subtotal').innerText; } //function custRound(x,places) { //return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) //} // End -->s </script> </head> <body onLoad="MM_preloadImages('../images/'), doMath()" > <tr><td align="center"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" bgcolor="#b6df51"><table width="800" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><form action="<?php echo $_SERVER['PHP_SELF'] . "?action=update"; ?>" method="post" name="frmCart" id="frmCart"> <td align="center" bgcolor="#b6df51"><table width="800" border="0" cellspacing="0" cellpadding="0" > <tr> <td align="left"><img src="images/title_purchase_online.gif" width="280" height="25" /></td> </tr> <tr> <td> </td> </tr> <tr> <td align="center"><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="800" border="0" cellpadding="0" cellspacing="0" bgcolor="#3b7b37"> <tr> <td width="15"><img src="images/title_box_left.gif" width="15" height="30" /></td> <td width="770"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" align="center" class="yellow_txt"><strong>Item</strong></td> <td width="213" align="center"> </td> <td width="141" align="center"><strong class="yellow_txt">Unit Price</strong></td> <td width="106" align="center"><strong class="yellow_txt">Quantity</strong></td> <td width="110" align="center"><strong class="yellow_txt">Total</strong></td> <td width="30" align="center"> </td> </tr> </table></td> <td width="15"><img src="images/title_box_right.gif" width="15" height="30" /></td> </tr> </table></td> </tr> <?php $subTotal = 0; for ($i = 0; $i < $numItem; $i++) { extract($cartContent[$i]); $productUrl = "other_products.php?c=$cat_id&p=$pd_id"; $subTotal += $pd_price * $ct_qty; ?> <tr> <td> </td> </tr> <tr> <td align="center"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" align="center" class="yellow_txt"><table width="150" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> </tr> <tr> <td width="116" align="center" valign="top" bgcolor="#b6df51"><a href="<?php echo $productUrl; ?>"><img src="<?php echo $pd_thumbnail; ?>" width="116" height="116" border="0" /></a><a href="<?php echo $productUrl; ?>"></a></td> </tr> <tr> </tr> </table></td> <td width="220" align="left" class="green_txt"><strong><a href="<?php echo $productUrl; ?>" style="text-decoration: none"><font color="000000"><?php echo $pd_name; ?></font></a></strong></td> <td width="128" align="center"><strong class="black_txt" id="pd_price"><?php echo displayAmount($pd_price); ?></strong></td> <td width="112" align="center"><input name="txtQty[]" type="text" id="txtQty[]" size="5" value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);"> <input name="hidCartId[]" type="hidden" value="<?php echo $ct_id; ?>"> <input name="hidProductId[]" type="hidden" value="<?php echo $pd_id; ?>"></td> <td width="110" align="center"><strong class="black_txt" id="ct_qty"><?php echo displayAmount($pd_price * $ct_qty); ?></strong></td> <td width="30" align="center" valign="middle"><a href="#"> <img src="images/btn_delete.png" width="16" height="16" border="0" onClick="window.location.href='<?php echo $_SERVER['PHP_SELF'] . "?action=delete&cid=$ct_id"; ?>';" /></a> </tr> </table></td> </tr> <?php } ?> <tr> <td> </td> </tr> <tr> <td><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="13" height="13"><img src="images/text_box_big_left1.gif" width="13" height="13" /></td> <td width="774" height="13" bgcolor="#ffde00"><span class="style10"><img src="images/spacer.gif" width="13" height="13" /></span></td> <td width="13" height="13"><img src="images/text_box_big_right1.gif" width="13" height="13" /></td> </tr> <tr> <td bgcolor="#ffde00"> </td> <td height="50" align="center" bgcolor="#ffde00"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="132" align="center" class="yellow_txt"> </td> <td width="147" align="left" class="green_txt"> </td> <td width="113" align="center"> </td> <td width="102" align="center" class="black_txt"><strong>Sub-total</strong></td> <td colspan="2" align="center"><strong class="black_txt" id="subtotal"><?php echo displayAmount($subTotal); ?></strong></td> <td width="19" align="center" valign="middle"> </td> </tr> <tr> <td colspan="7" align="center" class="yellow_txt"><img src="images/spacer.gif" width="10" height="10" /></td> </tr> <!-------------------------------------------- shipping cost---------------------------------------------------> <tr> <td align="center" > </td> <td align="left" class="green_txt"> </td> <td> </td> <td align="center" class="black_txt"><strong>State</strong></td> <td colspan="2" align="center"> <select name="state"> <option value="east" selected>East </option> <option value="west">Peninsular</option> </select> </td> <td align="center" valign="middle"> </td> </tr> <tr> <td colspan="7" align="center" class="yellow_txt"><img src="images/spacer.gif" width="10" height="10" /></td> </tr> <tr> <td align="center" class="yellow_txt"> </td> <td align="left" class="green_txt"> </td> <td align="center"> </td> <td align="center" class="black_txt"><strong>Shipping</strong></td> <td width="131" align="right"> <strong class="black_txt"> MYR</strong><!--<input type="text" name="amount" disabled="disabled" size="17" style="background-color:transparent;" border="none" >--></td> <td width="122" align="left"><strong class="black_txt"> <div name="amount" id="amount"> 0</div></strong></td> <td align="center" valign="middle"> </td> </tr> <tr> <td align="center" class="yellow_txt"> </td> <td align="left" class="green_txt"> </td> <td align="center"> </td> <td align="center" class="black_txt33"> </td> <td colspan="2" align="center" class="black_txt33"> <font color="#FF0000">*Purchases of 8 boxes onwards free delivery charges.</font> </td> <td align="center" valign="middle"> </td> </tr> <!------------------------------------------------------------------------------------------------------> <tr> <td colspan="7" align="center" class="yellow_txt"><img src="images/spacer.gif" width="10" height="10" /></td> </tr> <tr> <td align="center" class="yellow_txt"> </td> <td align="left" class="green_txt"> </td> <td align="center"> </td> <td align="center" class="black_txt"><strong>Total</strong></td> <td width="131" align="right"> <!--<input type="text" name="amount" disabled="disabled" size="17" style="background-color:transparent;" border="none" >--><strong class="black_txt"> MYR</strong></td> <td colspan="2" align="left"><strong class="black_txt" id="total"><?php echo displayAmount($subTotal);// + $shopConfig['shippingCost']); ?></strong> </td> <td width="4" align="center" valign="middle"> </td> </tr> <tr> <td colspan="7" align="center" class="yellow_txt"><img src="images/spacer.gif" width="10" height="10" /></td> </tr> <tr> <td align="center" class="yellow_txt"> </td> <td align="left" class="green_txt"> </td> <td align="center"> </td> <td align="center"> </td> <td colspan="2" align="center"><input type="button" class="update_btn" src="images/btn_update_cart.gif" width="102" height="22" border="0" name="btnUpdate" id="btnUpdate" onClick="doMath()"><!--value="submit"--></td> <td align="center" valign="middle"> </td> </tr> </table></td> <td bgcolor="#ffde00"> </td> </tr> <tr> <td width="13" height="13"><img src="images/text_box_big_left2.gif" width="13" height="13" /></td> <td bgcolor="#ffde00"><span class="style10"><img src="images/spacer.gif" width="13" height="13" /></span></td> <td width="13" height="13"><img src="images/text_box_big_right2.gif" width="13" height="13" /></td> </tr> <tr> <td> </td> </tr> </table></td> </tr> <tr> <?php $shoppingReturnUrl = isset($_SESSION['shop_return_url']) ? $_SESSION['shop_return_url'] : 'other_products.php'; ?> <tr> <td align="center"><table width="340" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> <td><a href="#"> <img src="images/btn_continue_shopping.gif" width="162" height="22" border="0" onClick="window.location.href='<?php echo $shoppingReturnUrl; ?>';" /></a></td> <?php if ($numItem > 0) { ?> <td width="20"> </td> <td><a href="#"> <img src="images/btn_continue_checkout.gif" width="162" height="22" border="0" onClick="window.location.href='checkout.php?step=1';"/></a></td> <?php } ?> </tr> </table></td> </tr> </table></td> </tr> <tr> <td align="center"> </td> </tr> </table></td></form> </tr> </table></td> </tr> </table> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <?php include("EmptyMSG.php"); ?> <!----<td><table width="550" bgcolor="#b6df51" border="0" align="center" cellpadding="10" cellspacing="0"><p align="center">You shopping cart is empty</p> <p>If you find you are unable to add anything to your cart, please ensure that your internet browser has cookies enabled and that any other security software is not blocking your shopping session.</p> </table></td>---> <?php } ?> </body> </html> checkoutConfirmation.php Code: [Select] <?php /* Line 1 : Make sure this file is included instead of requested directly Line 2 : Check if step is defined and the value is two Line 3 : The POST request must come from this page but the value of step is one */ if (!defined('WEB_ROOT') || !isset($_GET['step']) || (int)$_GET['step'] != 2 || $_SERVER['HTTP_REFERER'] != 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?step=1') { exit; } $errorMessage = ' '; /* Make sure all the required field exist is $_POST and the value is not empty Note: txtShippingAddress2 and txtPaymentAddress2 are optional */ $requiredField = array('txtShippingFirstName', 'txtShippingLastName', 'txtShippingAddress1', 'txtShippingPhone', 'txtShippingState', 'txtShippingCity', 'txtShippingPostalCode', 'txtPaymentFirstName', 'txtPaymentLastName', 'txtPaymentAddress1', 'txtPaymentPhone', 'txtPaymentState', 'txtPaymentCity', 'txtPaymentPostalCode'); if (!checkRequiredPost($requiredField)) { $errorMessage = 'Input not complete'; } $cartContent = getCartContent(); ?> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> </td> </tr> </table> </td> </tr> </table></td> </tr> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=3" method="post" name="frmCheckout" id="frmCheckout"> <table width="900" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" bgcolor="#b6df51"><table width="800" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> </tr> <tr> <td align="center"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" bgcolor="#b6df51"> <!------------------------------COD-------------------------------------> <?php if ($_POST['optPayment'] == 'cod') { ?> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="330" align="left"><img src="images/title_purchase_online.gif" width="280" height="25" /></td> <td width="464" align="left" valign="bottom"><img src="images/title_step02.gif" width="245" height="20" /></td> </tr> <tr> <td colspan="2"> </td> <p id="errorMessage"><?php echo $errorMessage; ?></p> </tr> <tr> <td colspan="2" align="center" class="green_txt"><table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#3b7b37"> <tr> <td width="15"><img src="images/title_box_left.gif" width="15" height="30" /></td> <td width="470" align="center" class="yellow_txt"><strong>:: IMPORTANT NOTE ::</strong></td> <td width="15"><img src="images/title_box_right.gif" width="15" height="30" /></td> </tr> </table></td> </tr> <tr> <td colspan="2" align="center"><img src="images/spacer.gif" width="12" height="12" /></td> </tr> <tr> <td colspan="2" align="center"> </td> <p id="errorMessage"><?php echo $errorMessage; ?></p> </tr> <?php } ?> <!-----------------paypal---------------------------------> <?php if ($_POST['optPayment'] == 'paypal') { ?> <tr> <td colspan="2" align="center"><table width="800" border="0" align="center" cellpadding="10" cellspacing="1" class="infoTable"><tr><td><table width="800" border="0" align="center" cellpadding="10" cellspacing="1" class="infoTable"> <tr> <tr> <td width="330" align="left"><img src="images/title_purchase_online.gif" width="280" height="25" /></td> <td width="464" align="left" valign="bottom"><img src="images/title_step02.gif" width="245" height="20" /></td> </tr> <td colspan="2" align="center" class="green_txt"><table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#3b7b37"> <tr> <td width="15"><img src="images/title_box_left.gif" width="15" height="30" /></td> <td width="470" align="center" class="yellow_txt"><strong>:: IMPORTANT NOTE ::</strong></td> <td width="15"><img src="images/title_box_right.gif" width="15" height="30" /></td> </tr> </table></td> </tr> <td colspan="2" align="center" ><table width="500" border="0" cellpadding="0" cellspacing="0" > <tr> <td align="center" class="black_txt33"><p>There will be (3.4% + RM2.00 MYR) PayPal transaction fee for credit card payment</p></td> </tr> </table></td> </tr> </table></td> </tr> </table> </td> </tr> <?php } ?> <!-----------------End of paypal----------------------------> <tr> <td colspan="2" align="center"><table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#3b7b37"> <tr> <td width="15"><img src="images/title_box_left.gif" width="15" height="30" /></td> <td width="470" align="center" class="yellow_txt"><strong>Ordered Item</strong></td> <td width="15"><img src="images/title_box_right.gif" width="15" height="30" /></td> </tr> </table></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"><table width="360" border="0" cellspacing="0" cellpadding="3"> <tr> <td align="left" class="green_txt"><strong>Item</strong></td> <td align="right" class="green_txt"><strong>Unit Price</strong></td> <td align="right" class="green_txt"><strong>Total</strong></td> </tr> <?php $numItem = count($cartContent); $subTotal = 0; for ($i = 0; $i < $numItem; $i++) { extract($cartContent[$i]); $subTotal += $pd_price * $ct_qty; ?> <tr> <td align="left" class="black_txt"><?php echo "$ct_qty x $pd_name"; ?></td> <td align="right" class="black_txt"><?php echo displayAmount($pd_price); ?></td> <td align="right" class="black_txt"><?php echo displayAmount($ct_qty * $pd_price); ?></td> </tr> <?php } ?> <tr> <td colspan="3" align="left"><img src="images/spacer.gif" width="12" height="12" /></td> </tr> <tr> <td align="left"> </td> <td align="right" class="green_txt"><strong>Sub-totall</strong></td> <td align="right"><span class="black_txt"><?php echo displayAmount($subTotal); ?></span></td> </tr> <tr> <td align="left"> </td> <td align="right" class="green_txt"><strong>Shipping<br /> </strong></td> <td align="right"><span class="black_txt"><?php echo displayAmount($shopConfig['shippingCost']); ?></span></td> </tr> <tr> <td align="left"> </td> <td align="right" class="green_txt"><strong>Total</strong></td> <td align="right"><span class="black_txt"><?php echo displayAmount($shopConfig['shippingCost'] + $subTotal); ?></span></td> </tr> </table></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center" class="black_txt"><strong><?php echo $_POST['optPayment'] == 'paypal' ? 'Paypal' : 'Bank-in / Bank Transfer'; ?> <input name="hidPaymentMethod" type="hidden" id="hidPaymentMethod" value="<?php echo $_POST['optPayment']; ?>" /></strong></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"><table width="380" border="0" cellspacing="0" cellpadding="0"> <tr> <td ><input name="btnBack" type="button" id="btnBack" onClick="window.location.href='checkout.php?step=1';" class="btn" ></td> <td width="20"> </td> <td><input type="image" src="images/btn_confirm_order.gif" width="132" height="22" border="0" value="Submit" name="btnConfirm" id="btnConfirm"></td> </tr> </table></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0"><tr></tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </form> </body> </html> thank you for the time and attention hello; it seems strange that php can set cookies, since php is on the serer-side, but the cookies are on the client-side ... is there something that I am missing? I have this page where I create two cookies with the username and passwords of the users for the website. Code: [Select] $equipa = $_POST['equipa'] ; $pass = $_POST['codigo'] ; setcookie("equipa", "$equipa", time() + 3600) ; setcookie("codigo", "$pass", time() + 3600) ; In the next page, I can have access to the cookie, with this script : Code: [Select] <?php $equipa = $_COOKIE['equipa'] ; echo $equipa ; $pass = $_COOKIE['codigo'] ; echo $pass ; ?> But in this page you have to fill a form and send it, going to a new page. In this new one, with the exact same code, I can't access the cookie. If anyone could please help me and tell me why..... Thanks for the help Im trying to use the following code; if($login_Remember) { /* Check if Remember Me was set */ setcookie('login_ID', $row['ID'], time()+3600 * 24 * 30); setcookie('login_Name', $row['Name'], time()+3600 * 24 * 30); setcookie('login_Access', $row['Value'], time()+3600 * 24 * 30); } header("Location: index.php"); When i try to use it, the only cookie thats registered is the bottom on "login_Access". None of the others are. I have tried everything but nothings working. I dont get any error messages. Using PHP v5.3.3 on IIS Please help. Thanks hi everybody ; its working Forgot Password i am posting a form.php to anohter page.php and if turn true i am sending mail and creating a cookie after header(Location: form.php) so cookie code in page.php Code: [Select] ob_start() sessioon_start $_COOKIE['mailsent'] = $mailii; setcookie("mailsent",$mailii,time()+(60*30)); i want show it Quote if(isset($_Cookie['mail'])) { echo "sent mail to $_Cookie['mailsent']" } but i am taking this Notice Quote Notice: Undefined index: kayip in J:\EasyPHP-5.3.2i\twww\site\form.php on line 133 when i lookup to site Cookies i am allready seem "mailsent" and value = $dynamic_mail so where am i doing wrong ?? |