Jump to content

dont show the form if it has been sucessfully processed.


Shaun

Recommended Posts

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!

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...

<?
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 } ?>

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.