Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'header() function'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. Here is a snippet of code right out of this book. I have been using it for years and it has always worked. Now, it just seems to die on me. It is supposed to take me from login.php to logged in.php. Instead, it goes to the line right after the header(), prints it and stops via exit(). The url in the browser still shows I am at login.php. There are no errors generated. After I log in with login.php (and it stops without going to loggedin.php), I will type the url for loggedin.php directly into the browser and it will get me to loggedin.php with the session already running. I.E., the privileges will all be set. So why isn't "login.php" redirecting me to "loggedin.php"? <?php # Script 11.8 - login.php #3 USING SESSIONS if (isset($_POST['submitted'])) { require_once ('includes/login_functions.inc.php'); require_once (CONNECTION); list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']); if ($check) { // OK! // Set the session data:. //session_name('glee');// this will refer to the last session by name instead of starting a new one ob_start();// start output buffering session_start(); $_SESSION['user_id'] = $data['user_id']; $_SESSION['first_name'] = $data['first_name']; $_SESSION['last_name'] = $data['last_name']; $name = $_SESSION['first_name'].$_SESSION['last_name']; // Redirect: $url = absolute_url ('loggedin.php'); //line below isn't working even though the value for $url is //http://localhost:8888/sites_in_progress/gill_truslowBS4/loggedin.php //(which is correct) header("Location:$url"); ob_end_clean();// stop output buffering echo "We have now gone past the header() function and are still at login.php"; exit(); } else { // Unsuccessful! $errors = $data; } mysqli_close($dbc); } // End of the main submit conditional. include ('includes/login_page.inc.php'); // THIS INCLUDES HEADER.HTML ?>
  2. Hello everyone! I'm new to the forum, so let me start by saying I'm happy to be here and that I'm learning a lot from Larry's (awesome!) books and I'm thoroughly enjoying them. I'm having a problem with HTTP Headers, specifically the header() function. Script 11.5, entitled "show_image.php" in Chapter 11, doesn't seem to work for me. I have tried it on two separate computers (desktop with Windows XP Pro, and laptop with Windows 7 Home) both using Firefox 11.0 and XAMPP 1.7.4 (which uses PHP 5.3.5). So, then I tried to test out the simple headers, like the ones Larry uses on pages 356 & 357 and they, too, seem to not be working correctly for me. Presumably this means that I am probably doing something wrong and/or need to change some settings, perhaps in the php.ini file. Anyhow, when I run the following simple program, the header redirects my browser to the url indicated, despite the fact that I put all kinds of HTML stuff before it. Here's the program: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>This is my title</title> </head> <body> <h1>Welcome to my website !</h1> <p>Insert witty banter in this paragraph...</p> <hr /> <a href="http://www.bbc.co.uk/news/">BBC News</a> <?php echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; #### a header() function to redirect the browser to The New York Times homepage... header('Location: http://www.nytimes.com/'); ?> </body> </html> And then, when I run a similar program with three headers for the browser to receive a PDF, everything seems to open or download, but my PDF readers (I tried Foxit and Adobe) keep giving me the following error (even when I omit all of the HTML stuff before the headers) in a dialog box: format error: not a PDF or corrupted. Anyhow, here is the second program: <?php #### 3 header functions for a PDF of the train schedule... header("Content-Type:application/pdf\n"); #### and I tried putting this PDF, and other PDF's and image files in various folders... header("Content-Disposition:attachment; filename=\"C:/xampp/htdocs/NJTransit.pdf\"\n"); #### I find the length, in bytes, by right-click, properties, size and size on disk header("Content-Length: 622592\n"); ?> It's probably something wrong with me and/or my computers, but needless to say it's driving me crazy, and I believe that I need to use HTTP headers in Chapter 12, "Cookies and Sessions." I'm wondering, for example, why the first program appropriately redirects the browser despite all of the HTML junk before it, and why the second program informs me that it's not a PDF or that it's corrupted. As for the second problem, I've tried many different things in a futile attempt to fix these problems, such as: moving the PDF to different folders using different PDF's and images, in multiple folders putting in different sizes (right-click, properties, size and size on disk) for header("Content-Length: 622592\n") trying these programs and others on separate computers... Everyone here seems much better at PHP than me, and by including both programs, someone may notice a common source of my frustration. Any help would be really, really appreciated! Thanks again!
×
×
  • Create New...