Jump to content
Larry Ullman's Book Forums

kwandoa

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by kwandoa

  1. I loaded PEAR successfully and loaded the the required packages but when I run login.php I get "Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\bin\php\php5.4.3\pear\Auth.php on line 469" and a "Strict standards: Non-static method DB::isConnection() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.4.3\pear\Auth\Container\DB.php on line 150" error. Would you be able to explain this pls? I am on a win7 system and a WAMP server.
  2. I have been to the PEAR website but find the installation instructions a bit vague. Is there another site that has in depth instructions for newbies? rgds
  3. Hi The scripts that I downloaded are not correct. chapter 4 examples are not present. is there an updated version of the scripts? rgds
  4. I would like to know where I can download the zip codes for this chapter. The link in the book does not work. rgds
  5. Hi Would you be so kind as to break down and explain the following: // Delete old sessions: $q = sprintf('DELETE FROM sessions WHERE DATE_ADD(last_accessed, INTERVAL %d SECOND) < NOW()', (int) $expire);
  6. Hi Sam. this link takes me to PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition) Regarding the problem I have. What i have done to try and debug is copied the style.css file into my includes file (as directed by the file structure in the book pg 54) and into a style folder that I created as the code directs <? <head> <title><?php echo $page_title; ?></title> <link rel="stylesheet" type="text/css" href="style/style.css" title="style" /> </head> ?> and still the css is not loading. I have gone back to 'PHP and MySQL for dynamic websites' book and also went through my working examples and that too has led me nowhere. What I have now done is gone to the website 'www.HTML5webtemplates.co.uk', downloaded another template and that HAS WORKED fine. So I assume that there is something wrong with the CSS file in the .zip file that I downloaded? pls advise
  7. I am busy with the chapter 2 templates section and my html template example does not look like the example in the book (header.html). I have loaded the css file. The footer seems to be ok. Is there an issue with the CSS template? or do u perhaps have a working example online?
  8. Hi I would like clarification on when to use echo and when to use print_r(). Also the 2 aurguments print_r() takes. I understand the variable $students but not the 1 in <? print_r($students, 1); ?>
  9. Regarding data validation and sanatizing, would it be considered wise to use HTML5 and Javascript data validation functions together with PHP data validation/sanatizing functions? I would think yes BUT I am concerned and don't understand what implications it could have on a production site.
  10. I understand why one would use the ($_SESSION['agent']), what I would like to ask though is why , in the conditional <? if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) )) { ?> you would use OR and not AND. I would think that you would check for both?
  11. Ok, I understand, makes sense. Could I just ask, why would you also add $dbc? Why not just email and pass?
  12. I have completed 'PHP and MySQL for Dynamic Web Sites Visual Quickpro 4th Edition' (well, almost done, I am on the last chapter) and I was wondering if, regarding this book, I can start on ch 6 'Basic OOP' or do you recommend I start from chapter 1?
  13. function redirect_user($page = 'index.php') { //define URL URL id http:// + host name + current directory $url = 'http://' .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']); //remove any trailing slashes $url = rtrim($url, '/\\'); //add the page: $url .= '/' .$page; //add slashes that u removed //redirect the user header("Location:$url"); exit(); //quit script } //end of redirect_user() /* This function validates the form data(the email address and password). If both are present, the database is queried. The function requires a database connection.The function returns an array of information, including: a TRUE/FALSE variable indicating success - an array of either errors or the database result */ function check_login($dbc, $email = '', $pass = '') { $errors = array(); // initialize error array if(empty($email)) { //validate the email and password $errors[] = 'You forgot to enter your email address'; } else { $e = mysqli_real_escape_string($dbc, trim($email)); } if(empty($pass)) { $erros[] = 'You forgot to enter your password'; } else { $p = mysqli_real_escape_string($dbc, trim($pass)); } if (empty($errors)) { //if no erros occurred, run the databse query // Retrieve the user_id and first_name for that email/password combination: $q = "SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = @mysqli_query($dbc, $q); //now check the results of the query: if(mysqli_num_rows($r) == 1) { //fetch the record $row = mysqli_fetch_array($r, MYSQLI_ASSOC); return array(true, $row); //return true and the record } else { //Not a match! $errors[] = 'The email and password entered do not matCH ThOse oN fiLe'; } } //End of empty($errors) IF //Return False and the errors: return array(false, $errors); } //End of check_login() function
  14. Great!!! awsome, now i understand!! I would like to use this method to validate forms and to play around with what HTML elements to load, depending on the user.
  15. How would one pass a php variable to a jQuery function. I would like to use jQuery to only show the delete and edit links if $_POST['user_id'] =1. // Table header: echo '<table align="center" cellspacing="0" cellpadding="5" width="75%"> <tr> <td align="left"><b>Edit</b></td> <td align="left"><b>Delete</b></td> <td align="left"><b><a href="view_users.php?sort=ln">Last Name</a></b></td> <td align="left"><b><a href="view_users.php?sort=fn">First Name</a></b></td> <td align="left"><b><a href="view_users.php?sort=rd">Date Registered</a></b></td> </tr> '; // Fetch and print all the records.... $bg = '#eeeeee'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['user_id'] . '">Edit</a></td> <td align="left"><a href="delete_user.php?id=' . $row['user_id'] . '">Delete</a></td> <td align="left">' . $row['last_name'] . '</td> <td align="left">' . $row['first_name'] . '</td> <td align="left">' . $row['dr'] . '</td> </tr> '; } // End of WHILE loop. echo '</table>';
  16. My form loads ok. login.php everything works like it should EXCEPT that when I submit the form with no password value I get the followoing error: Notice: Undefined variable: p in C:\EasyPHP\www\basicMySql\includes\login_functions.inc.php on line 41 But if i fill in a value, even a false one, the code works fine. could it be something to do with my isset()/empty() function?
  17. list ($check, $data) = check_login ($dbc, $_POST['email'], $_POST['pass']); Regarding the above. would you be able to go into a bit more detail. Another thing ... PHP.net states that it is not really a function "Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation." - php.net
  18. I have uninstalled and reloaded easyPHP and it does run it now BUT it does not show the file (header.html) in the EasyPHP admin page . It does show all the other files, including the 'h1.html'. If I go to the folder via windows7, i can see it... so i'm thinking it's an EasyPHP glitch...I can live with it for now.
  19. I guess you've been asked this many times...but amuse us this one time. In your opinion, if you met a beginner web developer and had to advise him/her on what Web Developing language to begin with, keeping in mind the Framework applications that are out there. Would you recommend PHP or Ruby?
  20. OMG! that was so obvious, maybe I should step away from the computer for awhile and take a break LOL. I take it then , that I cannot run the code without completing the login.php....
  21. I am not getting the desired results from the login lesson : Cookies and Sessions page 375 when i try and run http://127.0.0.1/basicMySql/includes/login_page.inc.php I get the form, which I complete BUT when I submit it I get taken to a http://127.0.0.1/basicMySql/includes/login.php which I have deleted from my directory(I am redoing this chapter which I did not get right the first time around). Would this be a cache problem?
×
×
  • Create New...