I'm writing a script for the easy admining of a database driven site. Currently I'm working a 'multipage Articles section'. This is not strictly a PHP related problem (I think) but here goes.
Everything is controlled by articles.php and all the functions reside in articles_functions.php. Nothing wrong with that. In the first instance of the form I use the user fills in all the details regarding the actual article and writes the first page. Now this works fine if thats where they want to stop and just submit a one page article. However if they want to go on and post more than one page they have that option given by the following:
<input type="submit" name="action" value="New Page">
<input type="submit" name="action" value="Finish Article">
<input type="reset" name="Reset" value="Clear Form">
Now this is submitted to articles.php and is handled by a switch statement.
switch($action)
{
case('New Page'):
if($pagenumber = 1)
{
AddArticle($articletype, $title, $publisher, $developer, $releasedate, $rating, $username);
}
$pagenumber += 1;
echo($pagenumber);
AddPage($title, $pagenumber, $body);
AddNewPage($pagenumber, $title);
break;
case('Finish Article'):
if($pagenumber > 1)
{
AddPage($title, $pagenumber, $body);
}
else
{
AddArticle($articletype, $title, $publisher, $developer, $releasedate, $rating, $username);
AddPage($title, $pagenumber, $body);
}
ShowArticlesMenu();
break;
}
As I say this works fine for the 'Finish Article' button and also the 'New Page button first time round. After clicking the 'New Page' button the user is shown another page via the AddNewPage function which this time only has the body of the new page to be filled in. It also contains the two previous varibles $pagenumber and $title that have been passed through from the main section. Heres the concated form.
function AddNewPage($page, $tit)
{
...
<input type="hidden" name="title" value="<? echo($tit) ?>"> <? echo($tit) ?>
<input type="hidden" name="pagenumber" value="<? echo($page) ?>"> <? echo($page) ?>
...
}
Now this page also uses the same buttons to submit the information and upon checking the code via View|Source in IE its supports that the page number has been incremented. Unfortunately upon submitting the info for a new page it again brings the same page number as the previous page without incrementing it. So the previous page number was 2 and the new pagenumber is 2, this remains so on 2 no matter how many times the 'New Page' button is pressed. It seems to me the cause of this problem is in the Posting of the same variable info back to the page and is not updating the previous info. Any suggestions would be welcomed!