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? $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; PHP:
if (mysql_query("INSERT INTO table VALUES ('whatever') WHERE something = 'something'")) { header("Location: whatever"); exit; } PHP:
What does the insert do? If it's to insert the values into the db I have that. That's not a problem. I'm concerned about: 1. how to add +1 to 0004.php to make it 0005.php 2. How to redirect to 0005.php.
Why did you wrote this then... Anyways.. $currentPage = substr($_SERVER['PHP_SELF'], 0, -4); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; header("Location: " . $nextPage); PHP:
It says : $currentPage = substr($_SERVER['PHP_SELF'], 0, -4); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; header("Location: " . $nextPage); //line 120 PHP:
Even when I echo it doesn't show the current page and the next: $currentPage = substr($_SERVER['PHP_SELF'], 0, -4); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; echo $currentpage; echo $nextpage; //header("Location: http://localhost/ebooks/pg_0005.php"); //header("Location: " . $nextPage); PHP:
If you don't mind using a bit of html: $currentPage = substr($_SERVER['PHP_SELF'], 0, -4); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; echo "<meta HTTP-EQUIV=REFRESH content=0; url=$nextPage>"; Code (markup): Try that. BTW: I think your echo does not work because you have to put: echo "$current[B]P[/B]age"; Code (markup):
Something seems wrong though. When I echo the nextPage it shows pg_0001.php. It doesn't redirect to the proper page. I'll have a second look at it.
You need to exit after a php redirect $currentPage = substr($_SERVER['PHP_SELF'], 0, -4); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; header("Location: " . $nextPage); exit; PHP:
$currentPage = substr($_SERVER['PHP_SELF'], 0, 7); $nextPage = sprintf("%04d", $currentPage + 1) . ".php"; echo "<meta HTTP-EQUIV=REFRESH content=0; url=$nextPage>"; Just a guess...might not work.
I think it needs quotes around the url right? But still didn't work. <meta HTTP-EQUIV=REFRESH content=10; url='http://localhost/ebooks/pg_0005.php'> Code (markup):
there's a problem: 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: echo "<meta HTTP-EQUIV=REFRESH content=10; url=" .$newurl. ">"; PHP: 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
No it doesn't. I mean when you put: echo "<meta HTTP-EQUIV=REFRESH content=10; url=" .$newurl. ">"; The sever automatically links the 2 red ones and the 2 navy ones. The double quotes at the start of the echo makes sure the script checks for any variables, so that covers that. Or you can do: echo '<meta HTTP-EQUIV=REFRESH content=10; url=" .$newurl. ">';
But it still doesn't work: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta HTTP-EQUIV=REFRESH content=10; url="http://localhost/ebooks/pg_0005.php" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> Code (markup): It refreshes the page instead of redirecting.