
phpRob
Members-
Posts
58 -
Joined
-
Last visited
-
Days Won
2
phpRob last won the day on December 21 2011
phpRob had the most liked content!
phpRob's Achievements
Newbie (1/14)
10
Reputation
-
Chapter 13 - My Project
phpRob replied to phpRob's topic in PHP for the Web: Visual QuickStart Guide (4th Edition)
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. -
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
-
Oh god yes, that is simple, how did I miss that, silly me! Thank you for the prompt reply though Larry.
-
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
-
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
-
Thanks Pete, all help would be very welcome, Thanks.
-
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.
-
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.
-
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!!
-
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!
-
Chapter 13 - Is_Administrator
phpRob replied to phpRob's topic in PHP for the Web: Visual QuickStart Guide (4th Edition)
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.