phpstuff
Members-
Posts
107 -
Joined
-
Last visited
Everything posted by phpstuff
-
Thank you anybody/everybody in advance for your help here... Ok, I give up... Been staring at this for a while. Was given this error message: Parse error: syntax error, unexpected $end in /Applications/XAMPP/xamppfiles/htdocs/Ch. Lessons/login.php on line 58 ***Line 58 is the last line of the code. I counted parenthesis and brackets and I believe everything matches up but I obviously have something wrong and its the first time I've hit a real brick wall in this book - I was hoping to get through it without any issues!! OS = OSX10.6.4 Browser = Firefox 22.0 Here is my code: <!DOCTYPE HTML> <html> <head> <title>Login</title> </head> <body> <h1>Login</h1> <?php //Script 11.8 - login.php //This script logs a user in by checking the stored values in a txt file. //Identify the file to use: $file = '../users/users.txt'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Handle the form $loggedin = FALSE; //Not currently logged in //Enable auto detect line settings: ini_set('auto_detect_line_endings', 1); //Open the file $fp = fopen($file, 'rb'); //Loop through the file: while ( $line = fgetcsv($fp, 200, "\t") ) { //Check the file data against the submitted data: if ( ($line[0] == $_POST['username']) AND ($line[1] == md5(trim($_POST['password']))) ) { $loggedin = TRUE; //Correct username/password combination. //Stop looping through the file: break; } //End of IF. } //End of WHILE. fclose ($fp); //Close the file. //Print a message: if ($loggedin) { print '<p>You are now logged in.</p>'; } else { print'<p style="color: red;">The username or password entered do not match those on file.</p>'; } } else { //Display the form. // Leave PHP and display the form. ?> } // End of submission IF. <form action="login.php" method="post"> <p>Username: <input type="text" name="username" size="20" /></p> <p>Password: <input type="password" name="password" size="20" /></p> <input type="submit" name="submit" value="Login" /> </form> </body> </html>
-
Mac OSX 10.6.4 Firefox 21.0 PROBLEM - I keep getting error message. I think the code is correct, but maybe the permissions for the txt file are not?? I included screen shots of the error, the permissions settings, and the code below. Here is my code: <!DOCTYPE HTML> <html> <head> <title>Add a Quotation</title> </head> <body> <?php //Script 11.1 - add_quote.php //This script handles and displays an HTML form, and takes text input and stores it in a text file. //First identify the file to use: $file = '../quotes.txt'; //Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { //handle the form if ( !empty($_POST['quote']) && ($_POST['quote'] != 'Enter your quotation here.') ) { //Need something to write. if (is_writable($file)) { //Confirm the file is writable file_put_contents($file, $_POST['quote'] . PHP_EOL, FILE_APPEND); //write the data //Print a message: print '<p>Your quotation has been stored.</p>'; } else { // Could not open the file. print '<p style="color: red;">Your quotation could not be stored due to a system error.</p>'; } } else { // Failed to enter a quotation. print '<p style="color: red;">Please enter a quotation!</p>'; } } // End of submitted IF. //Leave PHP and display the form: ?> <form action="add_quote.php" method="post"> <textarea name="quote" rows="5" cols="30">Enter your quotation here.</textarea><br /> <input type="submit" name="submit" value="Add this quote!" /> </form> </body> </html>
-
I did buy that book, as well as the PHP Advanced book (I'm serious about learing PHP!!). I already read the PHP & MySQL book and will be going through a second pass of the book to perform all the tutorials this time (I like to read the books first to understand the concepts and then go back through and actually do the coding. Once I get through the next book I'll probably be asking the same question as far as "what should one be able to make after reading this second book."
-
Hi, I'm curious what one should be capable of creating after going through this book? For example, I think one should be able to: 1. Create forms such as for contact forms, registration forms, etc 2. Create simple calculators (pg 274) such as mortgage loan calculator, interest calculation, etc. 3. Storing data in a database from a form. 4. Create reusable blocks of code to speed up devel time (functions ch. 10) 5. Random # generation 6. Formatting data / numbers 7. Create a basic template website (header, footer, sidebar) 8. Using Cookies/Sessions for better user experience What else am I missing here? What else can we "make" with the knowledge in this book? Thanks!