|
-
Dec 20th, 2007, 01:35 AM
#1
Thread Starter
Hyperactive Member
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] + 1 . $urlsnip[1] . $urlsnip[2] . $urlsnip[3] . $urlsnip[4];
//echo $thestringb . '<br />';
$newurl = str_replace($thestringa, $thestringb, $previousurl);
echo $newurl;
header( 'Location: ' . $newurl ) ;
exit;
-
Dec 20th, 2007, 06:27 PM
#2
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
-
Dec 20th, 2007, 07:16 PM
#3
Thread Starter
Hyperactive Member
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
-
Dec 20th, 2007, 07:50 PM
#4
Re: php redirect
then you need to use javascript redirect in replace of headers
My usual boring signature: Something
-
Dec 20th, 2007, 07:55 PM
#5
Thread Starter
Hyperactive Member
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?
-
Dec 20th, 2007, 07:58 PM
#6
Re: php redirect
i would suggest javascript...
<script type='text/javascript'>
window.location = 'w/e';
</script>
My usual boring signature: Something
-
Dec 20th, 2007, 08:23 PM
#7
Thread Starter
Hyperactive Member
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'>
-
Dec 20th, 2007, 08:40 PM
#8
Re: php redirect
did you try javascript like i suggested twice?
My usual boring signature: Something
-
Dec 20th, 2007, 09:07 PM
#9
Thread Starter
Hyperactive Member
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
-
Dec 20th, 2007, 09:09 PM
#10
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
-
Dec 20th, 2007, 09:16 PM
#11
Thread Starter
Hyperactive Member
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?
-
Dec 20th, 2007, 09:21 PM
#12
Thread Starter
Hyperactive Member
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. '" />';
-
Dec 20th, 2007, 09:29 PM
#13
Thread Starter
Hyperactive Member
Re: php redirect
How do I eliminate a 0 from pg_0001.php to add a 1 instead?
-
Dec 21st, 2007, 05:11 AM
#14
Re: php redirect
JavaScript and meta tag redirects are unreliable.
See: FAQ: Why Can't I Send Headers?
-
Dec 21st, 2007, 05:14 AM
#15
Re: php redirect
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|