Hi,
This was originally working ok 'ish but i've since rewritten it to include it within functions to make the code easier to understand.
Below is the basic code which if fails redirects to the relevant error page, yet if validation passes then in theory nothing should happen. The thing is even if validation is passed it's still redirecting to an error page, i've tried looking online and still can't find an answer, any ideas?
Thanks
<?php
$target_path = "images/uploads/";
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$quote = $_POST['quote'];
formvalidate();
function formvalidate(){
// Is username blank?
if(trim($username) == ''){
header('Location: error.php?code=1');
return false;}
// Is email blank?
else if(trim($email) == ''){
header('Location: error.php?code=1');
return false;}
// Is password blank?
else if(trim($password) == ''){
header('Location: error.php?code=1');
return false;}
// Is there a quote?
else if(trim($quote) == ''){
header('Location: error.php?code=1');
return false;}
return true;
}
?>
Tags: