Jump to content
Larry Ullman's Book Forums

phpRob

Members
  • Content Count

    58
  • Joined

  • Last visited

  • Days Won

    2

phpRob last won the day on December 21 2011

phpRob had the most liked content!

Community Reputation

10 Good

About phpRob

  • Rank
    Advanced Member
  1. Didn't think it would be wise to give away credentials. It was just a bit of fun really Larry, didn't want people to expect anything mindblowing, I just wanted to go through Chapter 13 with a different look to the user interface. I will probably use this base to add in a user registration, keep different users' details stored in the database and create a new quotes field within the database so that I could seperate different kinds of quotes, e.g. films, sports etc. That I'm sure I will learn in the second of your books hopefully.
  2. Hi Guys and Gals, Not been posting much recently, my php/mysql learning was put on hold durning the Christmas Hols and I'm just going over a few things to refresh before I hit the PHP & MYSQL for dynamic websites book. To refresh I went back over the last chapter (13) and thought I'd give it my own stamp if you like. Have a look and please rip it apart as it's just for learning purposes. Main reason for this was to gain a better feeling of how HTML, CSS, PHP and MYSQL all interact with each other, as well as gaining some practice with hosting a live dynamic website as I've mostly been testing locally. As in the book the login credentials are: Edit: 'm not sure if this is safe to publically give away the login credentials? Like I said if there's anything I've missed or that can be improved upon (within the PHP for the web book scope) please, please say The url is: http://www.blueberry....uk/gibberjabba Thanks Rob
  3. Oh god yes, that is simple, how did I miss that, silly me! Thank you for the prompt reply though Larry.
  4. Hey all, I'm currently adopting Chapter 13 into my own quotes database mini-site. The first task I've come across is on the login page. After the user has logged in I want it to re-direct to the homepage (index.php) rather than displaying a simple message as the following script does. My question is, how can I re-write the following script as per the book to allow for header() to be called? Would I have to use output buffering, or is there a bette way? <?php // Script 13.5 - login.php /* This page lets people log into the site. */ // Set two variables with default values: $loggedin = false; $error = false; // Check if the form has been submitted: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form: if (!empty($_POST['email']) && !empty($_POST['password'])) { if ( (strtolower($_POST['email']) == [email=""]'me@example.com'[/email]) && ($_POST['password'] == 'testpass') ) { // Correct! // Create the cookie: setcookie('Samuel', 'Clemens', time()+3600); // Indicate they are logged in: $loggedin = true; } else { // Incorrect! $error = 'The submitted email address and password do not match those on file!'; } } else { // Forgot a field. $error = 'Please make sure you enter both an email address and a password!'; } } // Set the page title and include the header file: define('TITLE', 'Login'); include('templates/header.html'); // Print an error if one exists: if ($error) { print '<p class="error">' . $error . '</p>'; } // Indicate the user is logged in, or show the form: if ($loggedin) { print '<p>You are now logged in!</p>'; } else { print '<h2>Login Form</h2> <form action="login.php" method="post"> <p><label>Email Address <input type="text" name="email" /></label></p> <p><label>Password <input type="password" name="password" /></label></p> <p><input type="submit" name="submit" value="Log In!" /></p> </form>'; } include('templates/footer.html'); // Need the footer. ?> Thanks
  5. All your doing in that above script is assigning the returned value from the function to a new variable '$total' so the result can be printed out. You might also want to check out the variable scope section a little further on in chapter 10.
  6. Hi guys, having finished Chapter 13 find myself at the Review section. I'm having trouble answering the following two review questions: How would the is_administrator() function be called to check for the same cookie - named Samuel - with a different value? A different cookie - not named Samuel - with a different value? I'm still unsure about this please help! AND What would be some other good ideas for user-defined functions wit this site? Hint: look for repeated code. Would printing an error message be viable for a function as this seems to be repeated a lot in the code throughout the project? What other ones could there be? Thanks
  7. <form action-"handle_form.php"method="post"> Should be <form action="handle_form.php"method="post"> Lke Jonathon recommended, look for a decent code editor, there are some good ones free for MAC and PC. Text wrangler and notepad++ are to decent ones. Netbeans is a good IDE which is also free.
  8. phpRob

    Introductions

    Thanks Pete, all help would be very welcome, Thanks.
  9. I've had a quick look too and also found this error <p><label>Name: <input type="text" name="name size="20" maxlength= "40" /></label></p> You have a html error here and you've missed the closing quotation on 'name', should be: <p><label>Name: <input type="text" name="name" size="20" maxlength= "40" /></label></p> Hope that helps too.
  10. PHP for the web covers the fundamentals of php at a much slower pace than that of the php & mysql book. It alsor includes an introduction chapter to sql and mysql which i found very helpful. I've nearly finished the php for the web book and will be working through the php & mysql book (4th edition) in the new year which I'm already looking forward to. Like Jonathon said, having both books by your side would be a great decision.
  11. phpRob

    Introductions

    Hi Redscouse, I guess I'm at the exact same position you found yourself in all that time ago, I'm just starting out at php & mysql having nearly finished Larrys' PHP for the web book. I'm hoping after reading Larrys other books and completing a couple of my own projects I'll be in a position to laugh at my own forum posts oneday!!
  12. Do you have to quote the values in the $_POST variable? function validate_text_input($input_name, $err_msg) { if (empty($_POST['$input_name'])) { $errors[] = $err_msg; } else { if (get_magic_quotes_gpc()) { $input_name = mysqli_real_escape_string($dbc, stripslashes(trim($_POST['$input_name']))); } else { $input_name = mysqli_real_escape_string($dbc, trim($_POST['$input_name'])); } } } Excuse me if this is nonsense, I'm just a beginner!
  13. Ooops, sorry Larry that is correct. if ( isset($_COOKIE[$name]) && ($_COOKIE[$name] == $value) ) { return true; } else { return false; } Could you explain the if statement, I still don't fully understand the logic.
  14. I too got a bit overwhelmed using the php manual to begin with, especially reading the User Contributed Notes, as a beginner I don't recommend reading those as they'll probably confuse the heck outta ya! . This is a helpful page on reading functions though thanks
×
×
  • Create New...