can you include arrays[] in header urls?
I have the following but it doesn't work so I am thinking it might not be possible.

$name  = strtolower($_POST["name"]);
$name = stripslashes(ucwords($name));
$email = strtolower($_POST["email"]);

$emailx ="/^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$/";
$alphaspace ="/^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/";

if ($name=="") 
{
$error[] ="Name is a required field please complete and submit it again.";
}
elseif (preg_match($alphaspace, $name) ==false)
{                    
$error[] ="Please fill in a correct value for name numbers are not allowed.";
}
if ($email=="") 
{
$error[] ="Email is a required field please complete and submit it again.";
}
elseif (preg_match($emailx, $email) ==false) 
{
$error[] ="Please fill in a correct email address";
}
for ($i=0; $i<count($error);$i++)
{
header ("location: ../careers.php?error=$error[$i]");
exit;
}

it's not possible in this case. How would the browser know to which page to jump, if there were two ? It will always jump to the first.

Why not make the following your code:

$name  = strtolower($_POST["name"]);
$name = stripslashes(ucwords($name));
$email = strtolower($_POST["email"]);

$emailx ="/^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$/";
$alphaspace ="/^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/";

if ($name=="") 
{
$error. ="Name is a required field please complete and submit it again.|";
}
elseif (preg_match($alphaspace, $name) ==false)
{                    
$error. ="Please fill in a correct value for name numbers are not allowed.|";
}
if ($email=="") 
{
$error. ="Email is a required field please complete and submit it again.|";
}
elseif (preg_match($emailx, $email) ==false) 
{
$error. ="Please fill in a correct email address|";
}
if (strlen($error)>0) {
$error=preg_replace('/(.*)\|/i','$1',$error);
}
header ("location: ../careers.php?error=".$error);
exit;

And to retrieve the array

<?
$error=explode('|',$_GET['error']);
var_dump($error);
?>

will that not produce just one error at a time?

No it wont! cwarn23 is appending a "|" after every error message. So, if there are 2 errors, the query string would look like,

Name is a required field please complete and submit it again.| Please fill in a correct email address|

I personally don't prefer doing it this way since the query string look quite long and bad. Maybe using a session array variable is a better choice.
Whenever there is an error, add it to a variable, then make that a session variable. After displaying respective error message, unset the session variable.

No it wont! cwarn23 is appending a "|" after every error message. So, if there are 2 errors, the query string would look like,

Name is a required field please complete and submit it again.| Please fill in a correct email address|

I personally don't prefer doing it this way since the query string look quite long and bad. Maybe using a session array variable is a better choice.
Whenever there is an error, add it to a variable, then make that a session variable. After displaying respective error message, unset the session variable.

Take a closer look at my script. Line 25. In my post I solved a way around the last appended | symbol by using the following line:

$error=preg_replace('/(.*)\|/i','$1',$error);

That preg_replace function makes the string look like

Name is a required field please complete and submit it again.| Please fill in a correct email address

So I see no reason why I will not convert to a proper array with the way I wrote the script.
Also if you think the url just looks ugly then simply use sessions.

Take a closer look at my script. Line 25. In my post I solved a way around the last appended | symbol by using the following line:

I was just giving him an example how the result would look like! I just copy pasted the error messages and I forgot to take the last "|" from it.

http://localhost/careers.php?error=Name%20is%20a%20required%20field%20please%20complete%20and%20submit%20it%20again.|Email%20is%20a%20required%20field%20please%20complete%20and%20submit%20it%20again.

This is exactly how it looks like (if there are 2 errors).

thanks but i think i will give each error a number value then get the number values on the next page less for the header to send accross

actually the script doesn't work at all lots of errors

worked to a certain extent but had to edit it a bit to get it working
thanks anyway on the $get there was an issue I added this to get it working var dump didn't work started showing all the array coding

$errors = $_GET["error"];
$error = explode('|', $errors);
for ($i=0; $i<count($error);$i++)
{
if ($error==true)
{
echo '<tr><td class="error">'.$error[$i].'</td></tr>';
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.