Reputation: 65
trying to create a retieve/recover form where a user can type their first and last name to retrieve an email address. I am not sure if I need to use an array to do this or if this way is fine as well, but I am getting a syntax error.
<br /> <br /><p3>Retrieve User Information</p3> <br /> <br />
<?php
if(isset($_POST['fist_name'], $_POST['last_name']) === true && empty($_POST['first_name'] , $_POST['last_name']) === false){
if(email_exists($_POST['email']) === true) {
retrieve('email');
}
}
else{
$errors[] = '<p1 class="postad_msg">Sorry, we could not find that email address!</p1>';
}
?>
<form method="post" action="retrieve">
<fieldset>
<label for="first_name">First Name * : </label>
<input placeholder="Your first name" type="text" name="first_name" size="30" maxlength="30" value="<?php echo htmlentities($first_name); ?>" /><br /><br />
<label for="last_name">Last Name * : </label>
<input placeholder="Your last name" type="text" name="last_name" size="30" maxlength="30" value="<?php echo htmlentities($last_name); ?>" /><br /><br />
</fieldset>
<fieldset class="center1">
<input class="submit" type="submit" name="submit" value="Retrieve Email" />
</fieldset>
<?php echo output_errors($errors); ?>
<?php echo output_message($message);?>
</form>
<?php
}
else{
header('Location: index');
exit();
}
?>
Thanks in advance!
Upvotes: 0
Views: 61
Reputation: 6369
No need for nested conditions. Simply use:
if( (isset($_POST['first_name']) && $_POST['first_name']) &&
(isset($_POST['last_name']) && $_POST['last_name']) &&
(isset($_POST['email']) && $_POST['email']) ) {
}
Notice that you had a typo in first_name.
Hope this helps!
Upvotes: 0
Reputation: 558
I write it quick so I didn't test it
but I think you will find out your mistake
<br /> <br /><p3>Retrieve User Information</p3> <br /> <br />
<?php
if (isset($_POST['submit'])) {
$mode_allowed = array('email', 'passwd');
if (isset($_GET['mode']) && in_array($_GET['mode'], $mode_allowed)){
if(isset($_POST['fist_name']) && isset($_POST['last_name']) && !empty($_POST['first_name']) && !empty($_POST['last_name']) ){
if(email_exists($_POST['email']) ) {
retrieve('email');
}
}
else{
$errors = '<p1 class="postad_msg">Sorry, we could not find that email address!</p1>';
}
?>
<form method="post" action="">
<fieldset>
<label for="first_name">First Name * : </label>
<input placeholder="Your first name" type="text" name="first_name" size="30" maxlength="30" value="<?php echo htmlentities($first_name); ?>" /><br /><br />
<label for="last_name">Last Name * : </label>
<input placeholder="Your last name" type="text" name="last_name" size="30" maxlength="30" value="<?php echo htmlentities($last_name); ?>" /><br /><br />
</fieldset>
<fieldset class="center1">
<input class="submit" type="submit" name="submit" value="Sign Up For A Vegizzle Account" />
</fieldset>
<?php if (isset($errors)) { echo output_errors($errors); } ?>
<?php if (isset($message)) {echo output_message($message); }?>
</form>
<?php
}
else{
header('Location: index');
exit();
}
}
else {
return;
}
?>
Upvotes: 0
Reputation: 2741
empty()
does not take multiple parameters.
You need to rewrite this way:
... empty($_POST['first_name']) === false && empty($_POST['last_name']) === false) {
Upvotes: 1