Code: Select all
//Display error messages.
} else {// if errors array is not empty
//Conver the errors array into a string
$errors_string = implode(" ", $errors);
//Encode the imploded string.
$message = urlencode($errors_string);
header("Location: register_page.php?message=$message");
}
And here is the code for the target page:
Code: Select all
</div> <!--closes register box-->
<div id="error">
<?php if(isset($_GET['message'])) {
//Decode the url
$errors_string = urldecode($_GET['message']);
//Explode the decoded errors string back to an array.
$errors = explode(" ", $errors_string);
echo '<h3>Error!</h3>
The following error(s) occured:<br />';
foreach ($errors as $msg) {
echo "$msg<br/>\n";
}
}
?>
</div> <!--closes error-->
Now everything works just fine, except that the error messages are printed one word per line for example
Your
is
not
a
valid
address.
I can't seem to find the fluke in the code. Any ideas? Also is there any potential security risk for passing error messages in a url? No sensitive information is being transmitted. Just error messages.