Jump to content
Larry Ullman's Book Forums

Johnamc328

Members
  • Posts

    28
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Johnamc328

  1. If it was just me I would say it is some weird fluke. But another user stated the same issue. Must be something on the back end somewhere if you took my code and it worked fine in your envrioment. I am doing this at work - I will try it at home and see what happens.
  2. I have tried it with IIS and Bitnami WAMP with the same result
  3. I tried to with my GoDaddy account but they have too many issues. Here is the source code of the page after it has ran <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <title>Add a Site Content Page</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/sticky-footer-navbar.css" rel="stylesheet"> </head> <body> <!-- Wrap all page content here --> <div id="wrap"> <!-- Fixed navbar --> <div class="navbar navbar-fixed-top"> <div class="container"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.php">Knowledge is Power</a> <div class="nav-collapse collapse"> <ul class="nav navbar-nav"> <li><a href="index.php">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> <li><a href="register.php">Register</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Account <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="logout.php">Logout</a></li> <li><a href="renew.php">Renew</a></li> <li><a href="change_password.php">Change Password</a></li> <li><a href="favorites.php">Favorites</a></li> <li><a href="recommendations.php">Recommendations</a></li> </ul> </li><li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="add_page.php">Add Page</a></li> <li><a href="add_pdf.php">Add PDF</a></li> <li><a href="#">Something else here</a></li> </ul> </li> </ul> </div><!--/.nav-collapse --> </div><!--/container--> </div><!--/navbar--> <!-- Begin page content --> <div class="container"> <div class="row"> <div class="col-3"> <h3 class="text-success">Content</h3> <div class="list-group"> <a href="category.php?id=3" class="list-group-item" title="Common Attacks">Common Attacks </a><a href="category.php?id=5" class="list-group-item" title="Database Security">Database Security </a><a href="category.php?id=1" class="list-group-item" title="General Web Security">General Web Security </a><a href="category.php?id=4" class="list-group-item" title="JavaScript Security">JavaScript Security </a><a href="category.php?id=2" class="list-group-item" title="PHP Security">PHP Security </a> <a href="pdfs.php" class="list-group-item" title="PDFs">PDF Guides </a> </div><!--/list-group--> </div><!--/col-3--> <div class="col-9"> <!-- CONTENT --> Array ( [status] => draft [title] => Test [category] => Array ( [0] => 3 ) [description] => Test [content] => <p>Test</p> [submit_button] => Add This Page ) <h1>Add a Site Content Page</h1> <form action="add_page.php" method="post" accept-charset="utf-8"> <fieldset><legend>Fill out the form to add a page of content:</legend> <div class="form-group"> <label for="status" class="control-label">Status</label> <select name="status" class="form-control"> <option value="draft">Draft</option> <option value="live">Live</option> </select></div> <div class="form-group"><label for="title" class="control-label">Title</label><input type="text" name="title" id="title" class="form-control" value="Test"></div><div class="form-group has-error"><label for="category" class="control-label">Category</label> <select name="category[]" class="form-control" multiple size="1"><option value="3">Common Attacks</option> <option value="5">Database Security</option> <option value="1">General Web Security</option> <option value="4">JavaScript Security</option> <option value="2">PHP Security</option> </select><span class="help-block">Please select a category!</span></div><div class="form-group"><label for="description" class="control-label">Description</label><textarea name="description" id="description" class="form-control">Test</textarea></div><div class="form-group"><label for="content" class="control-label">Content</label><textarea name="content" id="content" class="form-control"><p>Test</p></textarea></div> <input type="submit" name="submit_button" value="Add This Page" id="submit_button" class="btn btn-default" /> </fieldset> </form> <script type="text/javascript" src="js/tinymce/tinymce.min.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options selector : "#content", width : 800, height : 400, browser_spellcheck : true, plugins: "paste,searchreplace,fullscreen,hr,link,anchor,image,charmap,media,autoresize,autosave,contextmenu,wordcount", toolbar1: "cut,copy,paste,|,undo,redo,removeformat,|hr,|,link,unlink,anchor,image,|,charmap,media,|,search,replace,|,fullscreen", toolbar2: "bold,italic,underline,strikethrough,|,alignleft,aligncenter,alignright,alignjustify,|,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,", // Example content CSS (should be your site CSS) content_css : "/ex1/html/css/bootstrap.min.css", }); </script> <!-- /TinyMCE --> <!-- END CONTENT --> </div><!--/col-9--> </div><!--/row--> </div><!--/container--> </div><!--/wrap--> <div id="footer"> <div class="container"> <p class="text-muted credit"><span class="pull-left"><a href="site_map.php">Site Map</a> | <a href="policies.php">Policies</a></span> <span class="pull-right">© Knowledge is Power - 2013</span></p> </div> </div> <script src="js/bootstrap.min.js"></script> </body> </html>
  4. I put the code just below the category section and this displayed Array ( [status] => draft [title] => Text [category] => Array ( [0] => 5 ) [description] => Text [content] => Text [submit_button] => Add This Page ) Have tried with IE - Firefox and Chrome - all latest versions
  5. The main problem is I am not able to select one of them - I try but always get this message - I changed it to 1 instead of 5 but i still can not select one
  6. Here is the code that pertains to the dropdown echo '"><label for="category" class="control-label">Category</label> <select name="category[]" class="form-control" multiple size="5">'; // Retrieve all the categories and add to the pull-down menu: $q = "SELECT id, category FROM categories ORDER BY category ASC"; $r = mysqli_query($dbc, $q); while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; // Check for stickyness: if (isset($_POST['category']) && ($_POST['category'] == $row[0]) ) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } echo '</select>'; if (array_key_exists('category', $add_page_errors)) echo '<span class="help-block">' . $add_page_errors['category'] . '</span>'; echo '</div>'; create_form_input('description', 'textarea', 'Description', $add_page_errors); create_form_input('content', 'textarea', 'Content', $add_page_errors);
  7. Here is a screen shot - I am using the code from the book. I can't figure out why the Category will not do a drop down - the database connection is fine.
  8. True and I tried that but it did not make the drop down display so I though I was missing something with a relationship between two tables. I get just a textbox where it is supposed to be a drop down
  9. The first edition book file populates the table - not the ones with the second edition sql file - thanks for pointing me in that direction Even with the table filled the Categories is not a dropbox but a textbox - this line is different from the example select name="category[]"
  10. Yes local setup and using IIS and WAMP - here is all that the sql file has - just the tables creation CREATE TABLE `categories` ( `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `category` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `category_UNIQUE` (`category` ASC) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; I will try another DL and see what I get
  11. I apologise if I have missed something but the SQL statement that came with the download created the tables but did not populate the categories table. I try the add_page.php and it errors out because there is no data in the table. I have read through the chapter for the last 2 hours and can't find anything that populates the table but does refer to it such as this Each HTML page is in a single category. That association is made by attaching to each page record a foreign key to the proper value in the categories table. Where does the data for the categories table come from? Thanks, John
  12. I have found that when you use IIS and try the exercise with WAMP, LAMP etc is that you have default port settings for mysqli commands. If you are running IIS then those default ports are taken. If you are running a WAMP you have to go into the PHP inside the WAMP (IIS php is the regular php install) and change the port settings to the ones you selected when you installed WAMP. For example default ports are 80, 3306 and 443 - With a WAMP install most people choose 8080, 3307 and 4443 - in the php.ini you have to set the mysqli to 3307 instead of 3306 or the mysqli command to connect to the DB will not work. As for login problems - these have to be commented out - just in case anybody misses it like I did. // To test the sidebars: //$_SESSION['user_id'] = 1; //$_SESSION['user_admin'] = true; //$_SESSION['user_not_expired'] = true; $_SESSION=array(); So far everything is working fine - but I will be back with the harder example in part III since it is much more Apache server and I am just learning it now.
  13. I have been going through each chapter - the db is fine - the registration process works. Trying to figure out the IIS - includes problem since it is always with an included file where the trouble starts.
  14. So are the source files that are downloaded complete or do they still need modifying? I added the function to login.inc.php and it does not throw an error. It takes me to the home page. Then I put in a bogus email and it took me to the home page with no errors displayed. I entered a bogus PW and it took me to the home page with no errors displayed. It does not seem to be catching the errors - the register.php works fine with error checking, registering etc. Not sure why these include files are not catching errors.
  15. Hello, I have given up on Godaddy and WAMP. I am back to windows and IIS. I seem to be having a problem with the session since I always have the display showing Admin selections when I am classified as a user. I click on logout and they do go away. I click on the Home tab and they come back. I try the login and I get this error Fatal error: Call to undefined function escape_data() in C:\inetpub\wwwroot\ecommerce2\includes\login.inc.php on line 12 Any ideas are appreciated
  16. Something with phpmyAdmin - connection works fine with IIS connect - same settings
  17. I installed Bitnami WAMP - when it tries to connect to MySQL it bombs on this line mysqli_set_charset($dbc, 'utf8'); it gives this error mysqli_set_charset() expects parameter 1 to be mysqli, boolean given I googled it but can't find any current info - it did work fine under IIS
  18. I am going to install WAMP Stack - it may clear up some of these problems
  19. Someone brought this up - will the php code be seen if the extention is .html? That would explain why
  20. Hi Larry, Yes I am pretty familiar with PHP and MySQL - I have never got into the e-commerce portion before. Many other tutorials I have done do not have code in the header so that is why I am experiencing that now. I am developing locally and on GoDaddy at the same time just to see if it is possible to create a system for someone in the future. I am pretty sure that it is some issue with IIS. The Godaddy person said I should learn Linux but I am a little old to go down that road. I will updated when I have a solution.
  21. Upgraded back to 5.4 which is the highest Godaddy has - waiting on tech support since it bombs certain pages.
  22. I followed the wrong link from an earlier question about the same thing. I made the changes and here is what I have require "lib/password.php"; $hash = password_hash($password, PASSWORD_BCRYPT); An error occurred in script '\html\ecommerce2\register.php' on line 94: Undefined variable: password I have found out that I am having a problem with my IIS 7.5 - It will not see "require" - I am still trouble shooting to get the IIS correct. I will post my finding for future reference. Thanks
  23. Hello, I successfully logged out and tried to login. When I click to login it brings me to the default index.asp page with a "The website cannot display the page". When I just click on login without the email or PW it takes me to the default index.php page with no problems. The registration worked with no problems. The admin sections are not checking if I am an admin since the add pdf and add page sections show up with no problems and I have not set anyone up as an admin. These "require" as opposed to "includes" seem to not work with IIS - is there some setting I need to check?
  24. Hi Larry, Godaddy is at 5.4 but the site would not work until I reverted it back to 5.3. This is the link I found from another comment here https://sunnyis.me/blog/secure-passwords
×
×
  • Create New...