Shaun Posted October 12, 2008 Share Posted October 12, 2008 Ok, so I have simple form here that I want to do this with. when the from is sent, and the $msg is displayed, how do I hide the form under neath it when it succeeds, and show it when it fails? <? if (!empty($email)) { $result = mysql_query("Select * from users where email='$email'"); $totnum = mysql_num_rows($result); if($totnum>0) { $pw = mysql_result($result,0,"pw") ; include('pwmail.php'); $msg='success'; } else $msg="failer"; } ?> <table width="300" border="0" align="center" cellspacing="0"> <tr> <td><div align="left"> <h3 class="lthead">Forgot your password? </h3> </div></td> </tr> <tr> <td><?=$msg?><br /> Enter your email address:<br /> <form id="form1" name="form1" method="post" action=""> <input name="email" type="text" id="email" size="30" /> <input type="submit" name="Submit" value="Get it" /> </form> </td> </tr> </table> thank you so much for all your help! Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/ Share on other sites More sharing options...
Shaun Posted October 12, 2008 Author Share Posted October 12, 2008 Ok ive just tried: <? if (!empty($email)) { $result = mysql_query("Select * from users where email='$email'"); $totnum = mysql_num_rows($result); if($totnum>0) { $pw = mysql_result($result,0,"pw") ; include('pwmail.php'); $msg='You password has been sent!'; $state=1; } else $msg="error; $state=0; } ?> <table width="300" border="0" align="center" cellspacing="0"> <tr> <td><div align="left"> <h3>Forgot your password? </h3> </div></td> </tr> <tr> <td><?=$msg?><br /> <? if($state==1) {?> <? }else{?> Enter your email address.<br /> <form id="form1" name="form1" method="post" action=""> <input name="email" type="text" id="email" size="30" /> <input type="submit" name="Submit" value="Get it" /> </form> <? }?> </td> </tr> </table> But it still shows no matter what... Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663498 Share on other sites More sharing options...
waynew Posted October 12, 2008 Share Posted October 12, 2008 <? if (!empty($email)) { $result = mysql_query("Select * from users where email='$email'"); $totnum = mysql_num_rows($result); if($totnum>0) { $pw = mysql_result($result,0,"pw") ; include('pwmail.php'); $msg='success'; } else $msg="failer"; } if(isset($_POST['email']) && $msg == "success"){ ?> <table width="300" border="0" align="center" cellspacing="0"> <tr> <td><div align="left"> <h3 class="lthead">Forgot your password? </h3> </div></td> </tr> <tr> <td><?=$msg?><br /> Enter your email address:<br /> <form id="form1" name="form1" method="post" action=""> <input name="email" type="text" id="email" size="30" /> <input type="submit" name="Submit" value="Get it" /> </form> </td> </tr> </table> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663507 Share on other sites More sharing options...
DarkWater Posted October 12, 2008 Share Posted October 12, 2008 Wait wait wait. Are you programming with register_globals on? Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663509 Share on other sites More sharing options...
Shaun Posted October 12, 2008 Author Share Posted October 12, 2008 according to php info register_globals On On ? you have me worried. :S Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663512 Share on other sites More sharing options...
DarkWater Posted October 12, 2008 Share Posted October 12, 2008 according to php info register_globals On On ? you have me worried. :S You should be. register_globals was one of the stupidest things that the PHP development team ever concocted. What it does is it fills variables based on things from GET, POST, and COOKIES, and it can mess up your variables and make scripts insecure. Do you pay for hosting or is this your own server? Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663533 Share on other sites More sharing options...
Shaun Posted October 12, 2008 Author Share Posted October 12, 2008 I have my own server, I havent put this script live on it yet. It is just sitting on my home pc. Ive just googled and I guess im going to have to re code a lot of things.. Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663539 Share on other sites More sharing options...
DarkWater Posted October 12, 2008 Share Posted October 12, 2008 Yeah, and be sure to take register_globals off while you're at it. Link to comment https://forums.phpfreaks.com/topic/128119-dont-show-the-form-if-it-has-been-sucessfully-processed/#findComment-663543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.