Jump to content
Larry Ullman's Book Forums

Silver

Members
  • Posts

    52
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Silver

  1. Many thanks, HartleySan. In fact there is much code to it, but I am good to go now.
  2. Dear HartleySan, You are right, however, though the select element will be there in the final code, I ignored it here because I am able to manage it separately. I now want to do what I explained only, which I am unable to yet.
  3. Hi everyone. I'm trying to echo the values of an array inside HTML's <option> tag. The following should be echod: <option value="Moose Jaw,SK,Canada">Moose Jaw,SK,Canada</option> <option value="Prince Albert,SK,Canada">Prince Albert,SK,Canada</option> <option value="Regina,SK,Canada">Regina,SK,Canada</option> <option value="Saskatoon,SK,Canada">Saskatoon,SK,Canada</option> The code I attempted was: <!DOCTYPE html> <html> <body> <?php $sk=array("Saskatoon","Regina","Moose Jaw", "Prince Albert"); sort($sk); foreach ($sk as $value) { echo '<option value="'.$value.',SK,Canada">'.$value.',SK,Canada</option>'; echo "<br>"; } ?> </body> </html> Pls. note that the values of the array are not sorted alphabetically. The output, however, should be sorted in ascending format and be within the <option> tag after adding the province and country. Any help will be highly appreciated.
  4. Page 92, item 5 = should be added after >
  5. define ('BASE_URI', 'C:/xampp/htdocs/site/final/'); define ('BASE_URL', 'www.final/local/'); define ('MYSQL', '../mysql.inc.php'); Above were my config settings. Now I changed the base URL to 'www.final.local/' and it worked. Why wasn't working for the first setting? Is the BASE_URI & BASE_URL now in their best format or there could be a better way of writing them? Many many thanks, Larry.
  6. Dear Larry, Here are the tow cart scripts. As you see, both are downloaded from the forum. I am unsble to figure out where the problem is, and I would therefore appreciate your help. Many thanks. cart.html Note: begins with normal html view and table (not included here), which appears as designed. </table><br /><p align="center"><input type="submit" value="Amend Quantity" class="button" /></form></p><br /><p align="center"><a href="https://<?php echo BASE_URL; ?>checkout.php?session=<?php echo $uid; ?>" class="button">Checkout</a></p></div> Note: ends with the normal html view (not included here), which appears as designed. cart.php <?php require ('./includes/config.inc.php'); if (isset($_COOKIE['SESSION'])) { $uid = $_COOKIE['SESSION']; } else { $uid = md5(uniqid('biped',true)); } setcookie('SESSION', $uid, time()+(60*60*24*30)); $page_title = 'Your Shoppping Cart’; include ('./includes/header.html'); require (MYSQL); include ('./includes/product_functions.inc.php'); // If there's a SKU value in the URL, break it down into its parts: if (isset($_GET['sku'])) { list($sp_type, $pid) = parse_sku($_GET['sku']); } if (isset ($pid, $sp_type, $_GET['action']) && ($_GET['action'] == 'add') ) { // Add a new product to the cart: $r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, 1)"); } elseif (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the cart. $r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)"); } elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the cart. // Determine the quantity: $qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1; // Add it to the cart: $r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, $qty)"); // Remove it from the wish list: $r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)"); } elseif (isset($_POST['quantity'])) { // Update quantities in the cart. foreach ($_POST['quantity'] as $sku => $qty) { // Parse the SKU: list($sp_type, $pid) = parse_sku($sku); if (isset($sp_type, $pid)) { // Determine the quantity: $qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1; // Update the quantity in the cart: $r = mysqli_query($dbc, "CALL update_cart('$uid', '$sp_type', $pid, $qty)"); } } // End of FOREACH loop. }// End of main IF. // Get the cart contents: $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { // Products to show! include ('./views/cart.html'); } else { // Empty cart! include ('./views/emptycart.html'); } include ('./includes/footer.html'); ?>
  7. I do not know why the posted URL was incomplete. Here it is again: https://www.final/local/checkout.php?session=9a31881e6c08e8277b133e22794a0042
  8. Regret missing that out, Larry. It's: https://www.final/local/checkout.php?session=9a31881e6c08e8277b133e22794a0042
  9. Thanks Larry. Here is the details of what happens: In IE, typing https://final.local/ in the URL gives this message: “There is a problem with this website’s security certificate. The security certificate presented by this website was not issued by a trusted certificate authority. The security certificate presented by this website was issued for a different website address. … Continue to this website (not recommended)”. Apache Friends said a warning message could appear. Maybe they were referring to such a message. I also never assigned the certificate to a different website; I do not know if the message here could mean assigning the certificate to the same website but with the http protocol. Clicking on Continue to this website (not recommended) as appears in the above message, takes me to the index page of my website. The URL reads: https://final.local/ I then can move from the index page to browse products. For Kona coffe, e.g.,the URL reads: https://final.local/browse/coffee/Kona/3 When I click on add to cart, it adds my products and moves me to the cart page. The URL of the cart page reads: https://final.local/cart.php As you know, to go to the next page from this cart page I have to click on Checkout. When doing so, it does not take me to the next page but rather gives ‘Internet Explorer Cannot Display the Webpage.’ In Chrome, it does the same but the message is error 105, and in FF the error is server is not available .
  10. I am writing an e-commerce website in multiple languages, including some eastern languages that have numerals in their languages different than the Arabic numerals used worldwide. To give an example: Arabic Numerals: 0 1 2 3,… Urdu Numerals: ٠ ١ ٣ ٤,… In countries using such Urdu, Persian, etc. numbers, PC keyboards are configured differently, some keyboards are configured to enter the Arabic numerals, while the majority of keyboards are configured to enter their native numbers. This invited a need to design my website so that credit card numbers, address and phone numbers can accept different forms of numerals. Since orders, users, … tables should have one form of numbers only, I am thinking of a script in which the user can enter credit card numbers, address and phone numbers in multiple form numbers and then all forms are translated in the tables to be in one form only, Arabic numerals. I would appreciate sharing any ideas, scripts, etc. to achieve this.
  11. Dear Larry, I got some help and guidance from Apache Friends forum, which thankfully you recommended us in the book to turn to for server-related issues, and they managed to provide a better revised code for virtual host and certificate folders. Now the https works in the website, see this below working URL for the cart page: https://final.local/cart.php?action=add&sku=C4 Clicking on the Checkout from the cart page (the page in the above URL), however, does not take me to the next page but rather gives the same old error message of: Internet Explorer cannot display the webpage. I think now the server issue is over but there could be an error somewhere in the script which does not allow proper checkout. The code I am using is downloaded from your forum. Below is what Apache Friends provided: httpd-vhosts.conf NameVirtualHost *:80 NameVirtualHost *:443 <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> ServerName final.local ServerAlias www.final.local DocumentRoot "C:/xampp/htdocs/site/final" <Directory "C:/xampp/htdocs/site/final" > Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> ServerAdmin admins@final.local CustomLog final_local_access.log combined ErrorLog final_local_error.log LogLevel debug </VirtualHost> <VirtualHost *:443> ServerName final.local ServerAlias www.final.local DocumentRoot C:/xampp/htdocs/site/final <Directory "C:/xampp/htdocs/site/final" > Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> SSLEngine on SSLCertificateFile conf/ssl.crt/server.crt SSLCertificateKeyFile conf/ssl.key/server.key ServerAdmin admins@final.local CustomLog final_local_access_ssl.log combined ErrorLog final_local_error_ssl.log LogLevel debug </VirtualHost> Windows host file 127.0.0.1 localhost #::1 localhost 127.0.0.1 final.local 127.0.0.1 www.final.local For https connection, the above code relies on the default certificate came with the installation of Xampp 1.7.7, while in the script code, I updated the gateway_process.php using the respective values of login and transaction key obtained from Authorize.Net. If this could be the problem, how to resolve it? If something is the problem, kindly advise. My test certificate and key from Authorize.Net are about 10 days old. PHP 5.3.8, MySQL 5.5.16. Many thanks Larry.
  12. Many thanks for your support and advice, Zhaopeterson. It’s not a browser problem because I tried Chrome, FF, and IE but all gave the same result, which is fine in http but not checking out to https. I am still in need of assistance, therefore, any help from anybody is greatly appreciated.
  13. Many thanks Zhaopeterson for your support. I installed Xampp 1.7.7 and have IE9, however, my OS is vista pack2. In my system TLS 1.1, 1.2 are no there. By default, SSL 3 & TLS 1 are checked and I checked TLS 2 and restarted IE9 but it did not work. I am afraid there could be something else related to improper configuration of the SSL. I followed a number of tutorials on how to configure SSL on windows but none worked for me so far. Then I deleted Xampp and freshly installed Xampp 1.7.7. I am just a beginner on server/security, and would certainly need some help to get me pass this step. I am now trying to rely on the default certificate and key of the Xampp server, therefore, I did not make any changes to the directories and files of the Xampp 1.7.7. I would highly appreciate showing me what you have amended, enabled or disabled, added or deleted in your Xampp and Windows files to get your site working on the https protocol. Once more, I would really appreciate your support and step by step guidance because I am not strong on server/security and SSL issues. Presently the following are the only changes I made on the files: httpd-vhosts.conf (available on: C:/xampp/apche/conf/extra I made a virtual host as follows: NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot C:/xampp/htdocs ServerName localhost </VirtualHost> NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot C:/xampp/htdocs/site/final ServerName www.final.local </VirtualHost> Windows hosts (available on: C:/Windows/System32/drivers/etc 127.0.0.1 localhost ::1 localhost 127.0.0.1 www.final.local 127.0.0.1 https://www.final.local Config.inc.php (available on: C:/xampp/phpMyAdmin) Added my root password inside the quotation marks of: $cfg['Servers'][$i]['password'] = ''; My cURL is enabled, and I even switched off firewalls from windows and McAfee, but still I am unable to check out. Many thanks.
  14. I clicked on Xampp administration, and on its homepage is the following sentence: For OpenSSL support please use the test certificate with https://127.0.0.1 or https://localhost I clicked on the link and got the following error: "SSL connection error Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have. Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error." While I am still searching online for how to remedy this error, any quick guidance would be highly appreciated. In Windows my SSL 3 is selected.
  15. I tried but pages of local websites are not accessible via https--it gives the same generic message: Internet Explorer Cannot Display the Web Site.
  16. Thanks Larry, I installed Xampp 1.7.4 from Apache Friends.
  17. Hello friends, I forgot to add that the curl looks like: curl cURL support enabled cURL Information 7.20.0 Age 3 Features AsynchDNS Yes Debug No GSS-Negotiate No IDN No IPv6 Yes Largefile Yes NTLM Yes SPNEGO No SSL Yes SSPI Yes krb4 No libz Yes CharConv No Protocols dict, file, ftp, ftps, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp Host i386-pc-win32 SSL Version OpenSSL/0.9.8o ZLib Version 1.2.3 Also, I updated the gateway_process.php using the respective values of login and transaction key obtained from Authorize.Net. My system is Apache, Windows, both PHP & MySQL are release 5+.
  18. I have downloaded the coffee example code and it works fine, except: I am using a virtual host. Every time I go to the cart I see the previous list of items still there, which is acting like a sticky cart. Is this normal for virtual hosts or there is something wrong? I signed for an Authorize.Net Developer Test Account, and it seems the result was positive because I was given an API Login ID, transaction key, payment gateway, as well as a list of virtual credit cards numbers. But when I click on the Checkout from the cart page, I get ‘Internet Explorer Cannot Display the Webpage’ error message. I checked the Internet Options and found both SSL and TLS protocols enabled under the security section. The URL for the page that fails to connect is: https://www.final/local/checkout.php?session=85bcab41b9dc0faa030cfdb608c12b5f www.final.local is my virtual website. I would highly appreciate any assistant in checking me out.Both PHP & MySQL are 5+.
  19. I am assuming that: if (!empty($_POST[‘password’])) is NOT equal to if ($_POST[‘password’]) because the first is true only when something is written for password, while the later is true when password is posted even if it was blank. Pls. confirm if my understanding is correct or explain otherwise.
  20. Thanks Larry for the help. Yes “Error! Unfortunately a system error has occurred. ... We apologize for the inconvenience.” is displayed, which means the script includes the error.html rather than including list_coffees.html.
  21. Regarding my problem, I achieved some progress but not what I wanted. Here is what my pages look like: Index.php <?php require ('./includes/config.inc.php'); $page_title = 'whatever the final title might be'; include ('./includes/header.html'); include('./views/home.inc.php'); include ('./includes/footer.html'); ?> Home.inc.php <?php if (isset($_GET['type'], $_GET['category'], $_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $category = $_GET['category']; $sp_cat = $_GET['id']; if ($_GET['type'] == 'goodies') { $sp_type = 'other'; $type = 'goodies'; } else { $type = $sp_type = 'coffee'; } } require (MYSQL); $r = mysqli_query($dbc, "CALL select_categories('$sp_type', $sp_cat)"); if (mysqli_num_rows($r) > 0) { include ('/views/list_coffees.html'); } else { include ('./views/error.html'); } ?> So as you see, the index page includes the home page, which is significantly modified to allow for coffee products be displayed on the index page. All other pages and tables are kept per the book. Both PHP and MySql are release 5+. What I am getting now is the error message (last included page of the home.inc.php). Appreciate your help and guidance.
  22. Both PHP and MysQl are release 5+ I failed several attempts to get coffee products in the index page without goodies or sales products. I already called the stored procedures in the command line and got the proper results, however, how to get those products listed on the index page is the problem. Because I am dealing with the index, home, browse, and list_coffees, and most have goodies and sales, things did not work for me. The way I want the index page is to list ALL coffees products in the same way as they appear in Fig. 8.4. All coffees in the DB should be listed in the first view box of the view/home.html page, leaving the second box as is. there would be no need for the header menus to reach to the coffees products as products would be listed on the index page, the first page visitor sees. How would I amend all the relevant pages?
  23. You are right Jonathan. Say we save our files in a folder in XAMPP, htdocs. Are they 100% safe against theft/hacking there? I am also wondering if they might be vulnerable to theft/hacking by XAMPP itself. What steps do professionals take to ensure that while we program our website, it would always be protected from hackers?
  24. As everybody knows developing a site for business may take weeks or even months, during which the code remains in the text editor. With all information thefts and computer hacking that are taking place on personal computers, one is concerned how to protect the code inside the text editor. I would appreciate some help on the following: Is there a risk of hacking the code saved in a text editor? How is that possible? What should we do to prevent the stealing of such codes?
  25. Thanks Jonathan, for the info. you provided. The code was in HTML 4 or XHTML 1 (cannot recall now), but with the proper Doctype as I double checked it. When I googled the issue, I found others encountering the same problem. One person said they got a response from Google of an inherent Chrome problem.
×
×
  • Create New...