Results 1 to 15 of 15

Thread: php redirect

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    php redirect

    I'm making a script for inserting html pages into a database table. It's a 700-page ebook convert from pdf to html with the frames of page links on the left and navigation on the top.

    Within the pages, I added textareas and a submit button within a form. Everything works. THe problem is that I need to do this manually clicking each page link on the left frame 700 times.

    Since the forms on each page direct to a page where it inserts into the database table I need to put a redirect somehow that will lead to the next page. For example:

    I have
    http://localhost/ebooks/pg_0004.php

    And I want to go to:
    http://localhost/ebooks/pg_0005.php

    I came up with the following script to go incrementally
    http://localhost/ebooks/pg_0005.php
    http://localhost/ebooks/pg_0006.php...


    I'm open to any other suggestions on the script but how do I redirect to the next page automatically after the inserting into the database is finished?
    PHP Code:
         $myarray explode('000'$previousurl);
            foreach(
    $myarray as $value)
                {
                    
    $urlsnip $value;
                }
            
    $thestringa $urlsnip[0] . $urlsnip[1] . $urlsnip[2] . $urlsnip[3] . $urlsnip[4];        
            
    //echo $thestringa . '<br />';            
            
    $thestringb $urlsnip[0] + $urlsnip[1] . $urlsnip[2] . $urlsnip[3] . $urlsnip[4];
            
    //echo $thestringb . '<br />';
            
    $newurl str_replace($thestringa$thestringb$previousurl);
            
            echo 
    $newurl;
            
            
    header'Location: ' $newurl ) ;
    exit; 
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php redirect

    i have no idea what your code does...

    PHP Code:
    //your code here...

    //go to next page code...
    $pagenum '4'//lets say we are on page 4...
    $pagenum $pagenum++; //lets add a page, $pagenum now = 5

    header("Locastion: pg_$pagenum.php"); 
    My usual boring signature: Something

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    PHP Code:
    $pagenum '4'//lets say we are on page 4...
    $pagenum $pagenum++; //lets add a page, $pagenum now = 5
    echo $pagenum;
    header("Location: pg_000" $pagenum ".php");// Line 115 
    It doesn't work:
    4 (echo result from above)
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\ebooks\inserttext.php:6) in C:\xampp\htdocs\ebooks\inserttext.php on line 115
    Compare bible texts (and other tools):
    TheWheelofGod

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php redirect

    then you need to use javascript redirect in replace of headers
    My usual boring signature: Something

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    Which one's more recommendable JavaScript or HTML?
    PHP Code:
    echo "<meta HTTP-EQUIV=REFRESH content=0; url=$nextPage>"
    I wonder if there's a way to put a time delay before redirecting?
    Compare bible texts (and other tools):
    TheWheelofGod

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php redirect

    i would suggest javascript...

    <script type='text/javascript'>
    window.location = 'w/e';
    </script>
    My usual boring signature: Something

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    But still didn't work. It's not redirecting to that page.
    Code:
    <meta HTTP-EQUIV=REFRESH content=10; url='http://localhost/ebooks/pg_0005.php'>
    Compare bible texts (and other tools):
    TheWheelofGod

  8. #8
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php redirect

    did you try javascript like i suggested twice?
    My usual boring signature: Something

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    No I didn't try JavaScript. I'm using HTML and PHP.
    The problem is:

    My previous page is:

    http://localhost/ebooks/pg_0004.php

    The current page is:
    http://localhost/ebooks/inserttext.php
    This is where the script is found:
    PHP Code:
    echo '<meta HTTP-EQUIV=REFRESH content=10; url="' .$newurl'" />'
    When I echo $newurl; it gives me what I need:
    New URL: http://localhost/ebooks/pg_0005.php
    But it never goes there. Should I put the relative path or absolute ( including the http:...but it doesn't work.)


    The next page is:
    http://localhost/ebooks/pg_0005.php
    Compare bible texts (and other tools):
    TheWheelofGod

  10. #10
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php redirect

    i gave it the best shot i could, but i dont think i understand what your asking for. SOrry
    My usual boring signature: Something

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    Yeah but as I explained previously it won't work because I'm inserting each page in a database table. So each page has a form clickable using the post method to a page called inserttext.php ( to insert it to the db table ). So within the inserttext.php I have the redirect tag in the head section. It doesn't redirect but it refreshes.

    But as for:
    Code:
    <script type='text/javascript'>
    window.location = 'w/e';
    </script>
    I don't think it will work because it won't recognize the url. The url is recognized through the PHP carried into the inserttext.php to be executed to redirect. Do you understand what I'm talking about?
    Compare bible texts (and other tools):
    TheWheelofGod

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    It worked but check out the syntax, where the quotes are:
    PHP Code:
    echo '<meta HTTP-EQUIV=REFRESH content="10; url=' .$newurl'" />'
    Compare bible texts (and other tools):
    TheWheelofGod

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: php redirect

    How do I eliminate a 0 from pg_0001.php to add a 1 instead?
    Compare bible texts (and other tools):
    TheWheelofGod

  14. #14
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: php redirect

    JavaScript and meta tag redirects are unreliable.

    See: FAQ: Why Can't I Send Headers?

  15. #15
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: php redirect

    Quote Originally Posted by gilgalbiblewhee
    How do I eliminate a 0 from pg_0001.php to add a 1 instead?
    I'm afraid I don't understand the question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width