Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Johnamc328 last won the day on March 31 2015

Johnamc328 had the most liked content!

Community Reputation

1 Neutral

About Johnamc328

  • Rank
  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
  • Create New...