Problem with redirecting to page in array
Posted: Sun Aug 20, 2006 3:26 pm
I need to cycle through pages, pose some questions, evaluate the answers and iterate to the next page in the array.
The problem is how can I redirect to the next page in my array. I tried inlcude(); all seems OK but then I end up in an endless loop.
With header(); I get an error since I have to point to a full URL.
Here is an exert of my code: (bear in mind that this is real newbie stuff
)
I have another file which validates the info retrieved from foto*.html and if all is ok, jumps to the next page, much the same way I have above with
Obviously this isn't working, so any help is most welcome.
Thanks all, cheers
P.
The problem is how can I redirect to the next page in my array. I tried inlcude(); all seems OK but then I end up in an endless loop.
With header(); I get an error since I have to point to a full URL.
Here is an exert of my code: (bear in mind that this is real newbie stuff
Code: Select all
<!-- info.html >
<form action='valid_info.php' method='post'>
<!-- Form stuff goes here. >
</form>
Code: Select all
<?php
//valid_info.php
//Variables from info.html
$_nome1=trim($_POST['nome1']);
$_nome2=trim($_POST['nome2']);
$_idade = trim($_POST['idade']);
$_morada = trim($_POST['morada']);
$_cod_post1 = trim($_POST['cod_post1']);
$_cod_post2 = trim($_POST['cod_post2']);
$_local = trim($_POST['local']);
$_email = trim($_POST['email']);
if (!empty($_nome1) && !empty($_nome2) && !empty($_idade) && !empty($_morada) && !empty($_cod_post1) && !empty($_cod_post2) && !empty($_local) && !empty($_email))
{
//send info to DB (will do that later)
header('Location: array.php');
exit;
}
else
{
//jump to error page
header('Location: error1.html');
exit;
}
?>Code: Select all
<?php
//array.php
session_start();
$_SESSION['rand']= array('foto1.html', 'foto2.html','foto3.html', 'foto4.html', 'foto5.html', 'foto6.html', 'foto7.html', 'foto8.html', 'foto9.html', 'foto10.html', 'foto11.html', 'foto12.html', 'foto13.html', 'foto14.html', 'foto15.html', 'foto16.html','foto17.html', 'foto18.html', 'foto19.html', 'foto20.html', 'foto21.html');
$_SESSION['i'] = 0;
$_a = $_SESSION['rand'];
shuffle($_a);
//Problem start HERE:
header('Location: $_a[0]');
exit;
?>Code: Select all
header('Location: $_a[$_SESSION['i']]);Thanks all, cheers
P.