hello,
im trying to build an application that will incorporate a "forgot password" feature. in order for my feature to work correctly, i am asking the user to type in his/her email address and he/she will have to answer a security question.
in my php script, i created an array with only 3 questions. Every time the page is refreshed, or other users use the "forgot password" feature, i am implementing a random function which chooses a random index of the array and will hence display a different question every time.
my problem is, when i hardcode the php script into the html page right after the "Secret Question" it works perfectly fine and i see the questions randomly changing when the page is refreshed. The problem now is that i need to send that same question for verification in my database. I can not access this variable outside the .html page. Now, when i move the php block to another file, i can not randomly generate my question and insert it into the html page. i know i have to use the $_POST method but whatever i try is not working
can anyone shed some light on this? how to i use php to randomly generate an index in my array and then insert it into my html page?
the code that im using for my 3 random questions is:
im trying to build an application that will incorporate a "forgot password" feature. in order for my feature to work correctly, i am asking the user to type in his/her email address and he/she will have to answer a security question.
Code:
<form id="form1" name="form1" method="get" action="emailRetrieve.php" >
<label>Please enter your email address:</label><br/>
<label> Email address: <input type="text" name="emailText" id="emailText" size="50" /><br/><br/>
Secret Question: <br/>
Secret Answer: <input type="text" name="secretAnswer" id="secretAnswer" size="49" /><br/>
</label>
<input type="submit" value="Submit"/>
</label>
</form>
my problem is, when i hardcode the php script into the html page right after the "Secret Question" it works perfectly fine and i see the questions randomly changing when the page is refreshed. The problem now is that i need to send that same question for verification in my database. I can not access this variable outside the .html page. Now, when i move the php block to another file, i can not randomly generate my question and insert it into the html page. i know i have to use the $_POST method but whatever i try is not working
can anyone shed some light on this? how to i use php to randomly generate an index in my array and then insert it into my html page?
the code that im using for my 3 random questions is:
Code:
<?php
$securQueArr = array("1" => "what was your first car", "2" => "what is your mothers name", "3" => "which city were you born in");
$randInt = rand(1,3);
$securityQuestion = $securQueArr[$randInt];
?>
any ideas?
Comment