Search the Community
Showing results for tags 'conditional'.
-
Hey there guys, I am trying to create a forgotten password / username file named recover.php on this page a user will be able to validate his email to see if it exists and if so will send the information to that users registered email in the database. simple enough except i have a confusing issue with having multiple header redirects it seems. MY CODE: <?php ob_start(); include('include/init.php'); logged_in_redirect(); include('include/header.php'); ?> <h1><span>Forgot your username / password ? </span></h1> <p>In just a couple easy steps, we can recover your info and get you back on your way in no time ! <span style="color:#FF0000">( * All Fields are required )</span></p> <? $mode_allowed = array('username','password'); if(isset($_GET['mode']) === true && in_array($_GET['mode'], $mode_allowed) === true) { if(isset($_POST['forgot_email']) === true && empty($_POST['forgot_email']) === false ){ if(email_exists($_POST['forgot_email']) === true) { echo 'ok'; // <----- HERE I WANT TO REPLACE WITH A FUNCTION CALLED RECOVER(); && HEADER(); /* recover($_GET['mode'], $_POST['forgot_email']); header('Location: recover.php?success'); <---- REPLACE "ok" with THIS CODE exit(); */ } else { echo '<p>We could not find this email in our database ! Are you sure you got the right email ?</p>'; } } ?> // FORM BEGINS FOR USER TO SUBMIT THEIR EMAIL FOR VALIDATION <div class="recover_user_info"> <div id="change_password" style="float:left;"> <table style="margin-left:10px; margin-top:10px; margin-bottom:10px;"> <form name="forgot_data" action="" method="post"> <tr> <td class="register_td_left"><span class="">Please enter your email here:</span></td> <td class="register_td_right" colspan="2"><input type="email" name="forgot_email" size="60" maxlength="60" value=""></td> </tr> <tr> <td class="register_td_left"></td> <td class="extra_data" colspan="2"></td> </tr> <tr><td class="register_td_left"></td><td class="extra_data2" colspan="2"><input class="register-button" type="submit" name="forgot_userdata_button" value="Recover my info"></td></tr> </tbody></table></form> </div> </div> <? } else { die('Utter confusion ensues'); //<--- MAIN REDIRECT FROM ISSET CONDITIONAL.. REPLACE die('utter confusion ensues'); WITH header('Location: index.php'); exit(); } ISSUE: when i click submit without any of the header() in place i get an output of "ok" , which is exactly what i want. now when i place the extra code as shown above in the // brackets , the conditional fails and i get the die('utter confusion') when i add just the main header redirect to send a user back to index for not having a the correctly defined "$data_mode" , the code still works. its when i add the second header(), for when the form is being submitted and redirecting to recover.php?success that it wont function correctly. mind you, i have not even inserted the function of recover(); i was commenting it out, just to get the redirect to the success. anytime i click submit with both header() functions declared i get sent back to the index.php or die('utter confusion ensues'); any suggestions as to why this is happening ? i really cant figure out why the conditional passes if no header is the output , yet when the header is present to be outputted , the entire conditional fails.
- 4 replies
-
- php
- conditional
-
(and 1 more)
Tagged with: