Include file not returned when called

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

Include file not returned when called

Post by jarow »

2 questions: 1) Why won't the include file appear when called? and 2) How can I get both die messages to appear if both are false...right now if passwords don´t match and email is in wrong format only "passwords did not match" appears. If passwords match but email is incorrect format the "invalid email address" is returned. How can I get both to appear at once if both are incorrect?

Thanks

Code:
<?php
if ($password != $password2) {
die('Passwords did not match.');

}
}
if (!preg_match("/.*@.*..*/", $_POST['email_address']) | preg_match("/(<|>)/", $_POST['email_address'])) {
die('Invalid e-mail address.');

}
include 'join_fauna.php';

?>
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

This might work ("|" & "AND" operator precedence?) but if not you should see what I'm getting at.

Code: Select all

if(!preg_match("/.*@.*..*/", $_POST['email_address']) | preg_match("/(<|>)/", $_POST['email_address']) AND $password != $password2) {
    die('Password did not match and email is invalid.');
} ELSEIF ($password != $password2) { 
    die('Passwords did not match.'); 
}  ELSEIF (!preg_match("/.*@.*..*/", $_POST['email_address']) | preg_match("/(<|>)/", $_POST['email_address'])) { 
    die('Invalid e-mail address.'); 
} ELSE {
    include ('join_fauna.php'); // you had: include 'join_fauna.php';
}
Or:

Code: Select all

unset($nopass); unset($bad_email);
IF ($password != $password2) { 
    $nopass = 'Passwords did not match.'; 
} 
IF (!preg_match("/.*@.*..*/", $_POST['email_address']) | preg_match("/(<|>)/", $_POST['email_address'])) { 
    $bad_email = ' Invalid e-mail address.'; 
} 
IF (isset($nopass) OR isset($bad_email)) {
    die("$nopasss . $bad_email"); 
} ELSE {
     include ('join_fauna.php'); 
}
Post Reply