Jump to content
Larry Ullman's Book Forums

johannsnr

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About johannsnr

  • Rank
    Member

Recent Profile Visitors

195 profile views
  1. Hi Vicky, you can accomplish this by implementing rewrite rules. When the user logs in successfully the rewrite rule will switch the site to https, similarly when she logs out the site reverts to http and your login session is destroyed.
  2. Since last I spent days playing around with COOKIES and SESSIONS, trying to break the system so to speak to teach myself. I understand it better now. PS The 25 sites are scaled down to 1, I almost gave up and then gave it another go and another and another and another..... Nearly ended in divorce, but in the end a bit of success. Changed a lot of code and a lot of trial and error. Learned that with web development it is ongoing changes and using feedback making small changes. Check it out http://7daygardens.com.au I'll appreciate critisism
  3. ok so I have opted to run a query in the php file separately, then I realized that if (rows) can equal to 2, if for instance an email and mobile was found in the table. In both instances if a record was found I simply did not add the record and only retrieved a customer_id to be used later. I am concerned a little with security from that perspective.
  4. Why cannot I enter more than 127 items as quantity in the cart. I have tried and changed quantity in carts table from tinyint to smallint and that does not help. The maximum quantity of one item that can be selected is 127.
  5. The procedure add_customer on the coffee site simply adds a new customer to the table without checking if the current customer isn't already in the database. Is there a way to prevent duplicate customer records and how would the code change for example if (mysqli_num_rows($r) == 0) { call add_customer} if (mysqli_num_rows($r) == 1) { //thus the customer is in database and cannot be added again use information in database}
  6. Hi Larry, Thanks for your reply. I struggled with the code for another 24hours and then decided to chuck the original cookie code. I also changed my server to redirect www.example.com to example.com as the server read served both and the site configuration is only example.com. Even with the server configuration changed the original code still did not work correctly. Then the PHPSESSID cookie as in the original code I could not get to work so I changed the code as follows //check for session if (isset($_SESSION['user']) && (strlen($_SESSION['user']) === 32)) { $uid = $_SESSION['user']; } else { $uid = openssl_random_pseudo_bytes(16); $uid = bin2hex($uid); $_SESSION['user'] = $uid; Then on the checkout.php redirect user back to cart.php if no session is stored. This worked. I clearly still don't understand COOKIES and SESSION values like I should and it is a huge problem for me because I have currently 25 sites I am working on and all use sessions and cookies in some way or form. Do you know of books available on the subject, because I would like to know and understand this better. Thanks Johann Snr
  7. Hi Larry I have to a point given up on understanding what the problem is because the code simply don't work. I have spent more than a week 14 to 16 hours a day trying to figure out where the problem is and I got nowhere. Looks like using cookies and sessions in browsers are just impossible and the results are never what you expect. Another way should be found! I have tried changing the code to something simple like just returning the session id and that does not even work, so I have no clue where to go from here which means my whole website project is in the water, together with my business. Searching the web for answers is pointless. I have been working on this project for 2 years all together and this simple thing of sessions is destroying it and I have trying numerous browsers. I have changed my server setting to only use the domain without the www part and that does not work either thinking that the problem was in the url. I have tried different session values, different cookies every possible angle I could think of. Obviously without a session id on the site none of the code and database works so the whole thing is dead and nothing more than pages of code doing nothing. Not a happy camper at this stage! Not to mention the tons of books I have read up on this subject and none of them discuss sessions, cookie, browser behaviour and so on in detail. It is like building a car but there is no road to drive on. Can I perhaps mail you the code for my site, where the session issue start or maybe can you refer me to more info on sessions something practical that one can actually use, maybe you can write another books just on browser behaviour because it seems to be a real issue. I have even tried code separately checking for the current session id and that does not work either on multiple browsers, Firefox, Chrome, Edge none of them work. I can see the session from page to page, with your original code the cookie simply changes everytime the browser is refreshed. In the database the wrong value is recorded, usually the previous session id or new generated value. On the pages source view I can see the values of the cookie and session but other than that, the history or previous sessions I can't so I have no idea what is happening. The first couple of lines in cart.php where it checks for the COOKIE that simply ignores it and generates a new value so when checkout is selected the cookie values don't match and all you get is the emptycart.html. ANY HELP or IDEA?
  8. I am very disappointed in this forum which is supposed to be to help with question. I have posted on this topic more than once asking for help with not a single response from the writer. I have bought no less than 5 of your books, Larry and now I am struggling with no response from you. Perhaps it is time for me to seek another writer. I am sure I am making a beginner mistake but need a little help in finding the solution. Your response will be greatly appreciated.
  9. A little help would be appreciated on this problem, please. I had another stab at it and as far as I can figure out is that at the start of pages leading up to billing.php somewhere I have a problem. That is that, I think there is a problem in the code in the way I display the products where a customer can select a product and add it to his cart. Reason I figured is if I add a product to a cart everything works until I proceed to checkout, but if I update quantities before checkout it works fine. Hope my explanation makes sense. Please anyone??
  10. This morning the problem is back. Could anyone perhaps give some insight to this problem, because it does not make any sense whatsoever.
  11. found the culprit, but don't understand why. In cart.php on line 17 // Send the cookie: setcookie('SESSION', $uid, time()+(60*60*24*30), '/' ); and changed it to // Send the cookie: setcookie('SESSION', $uid, time()+(60*60*24*30)); which solved the problem, if I add my domain nothing works. Larry maybe you can shed some light here. Am I making a noob mistake or am I missing something from php.ini because my path is set to root in php for cookies.
  12. I have built and tested more than one website using Larry's model and the new site was working to a point, I think up to billing.php and then it stopped. If I remember correctly there was a update from Microsoft for edge, but I have tried the website in Firefox and Chrome with the same problem. I have a running server with Ubuntu and Nginx. It does create the sessions just not the same one, so for every php file and view page a different session is created and when you close the browser, delete history and cookies and then open the browser again it will bring up the original cookie up to cart.php. From what I can see and tested as soon as you go to checkout.php it checks for the cookie and can't find it so it redirects the user back to cart.php which then creates a new cookie and then obviously the cartempty view is displayed because there is nothing in the cart because of a new cookie.
  13. Hi I am having trouble with setcookie and php sessions. In the file cart.php it creates or checks for a cookie. That works fine and I can find the same cookie id in phpmyadmin in carts table. The problem is when I click on 'checkout' the next page shows emptycart.html and redirect to cart.php. In the browser a new cookie id was generated and sometimes a new phpsession as well that does not match up with the cookie id in carts table. HELP!
  14. Hi Everyone, After struggling for some fare amount of time with this I have found that the AuthorizeNet.php should be replaced with autoload.php found in the anet_php_sdk folder. In billing.php on line 158 where it is asking for ./AuthorizeNet.php it should point to ./autoload.php. Once I did that I had to change my php configuration to allow for the function curl_init() to be active. Remove the ; in front of extension = php_curl.dll (line 883 on my installation of php.ini). After that the system asked for class zend mime part. in email_receipt.php. I commented out lines 64 to 98 to test if it will work. It did but without sending the mail obviously. Larry please correct me if there is a mistake in my method here. This worked for me so far except the section about class zend mime which I have no clue about how to fix. With the changes and testing the site it at is giving me the ORDER COMPLETE page. regards johannsnr
  15. Hi Everyone I am struggling with the same issue. The AuthorizeNet.php file is missing in the download. There is however a file under the LIB folder AthorizeNetAIM.php. Unfortunately using this file creates another error which relates to a class AuthorizeNetRequest which it cannot find (line 42 in the script) AuthorizeNet website does not really offer much in terms of a solution either. Anybody got any idea how to fix this? regards johannsnr
×
×
  • Create New...