Re: [PHP-DB] Redirect upon successful form submission

[email protected] (Vinay Kannan)
Newsgroups php.db
Message-ID <[email protected]>
Thanks Bastien,

To be honest I have no clue as to how to hold the form in the buffer. I've
copied the code below, that might help I guess.


<?php include("header.php");
include("lib/funcs.php");
$url=$_SERVER['REQUEST_URI'];
$member_no=$_POST['member_no'];
$member_no=trim(htmlspecialchars($member_no));
$not_member=1;
if(isset($_POST['submit']) && $_POST['trigger']==6)
{
//  echo $member_no;
  $conn=mysql_connect($host,$user,$pass) or die("Could not open the
connection");
  $dbselect=mysql_select_db($dbname,$conn) or die("could not connect to the
DB");
  $id_query="SELECT * FROM members WHERE member_id='$member_no'";
  $result = mysql_query($id_query) or trigger_error("SQL", E_USER_ERROR);
  $num_rows=mysql_num_rows($result);
  //echo $num_rows;
  if($num_rows>0)
  {
    echo'<META HTTP-EQUIV="refresh" content="0;URL=member.php">';

  }

  else
  {

 $not_member=0;
   }


}
 ?>
<td width="420" class="whitebg">
<BR />
<h3 align="left">REFERENCE FOR MEMBERSHIP TO INFINITY LEARNERS CLUB</h3>
<p>
In order to be able to refer members to Infinity LMRC, you need to be a
registered member with us, Please enter your membership number below and
start referring.</p>
<table width="410">
<form action="<?php echo $url ; ?>" method="post" name="refer" >
<table>
<tr>
<td><label for="memberno">Membership Number</label></td>
<td><input type="text" name="member_no" class="myinput" /></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td><input type="submit" name="submit" value=" OK !" /></td>
<td><input type="reset" name="cancel" value=" Cancel " /></td></tr>
<tr><td><input type="hidden" name="trigger" value="6" /></td></tr>
</table>
</form>
<?php
if($not_member==0)
{
  echo 'Our records indicate that you are not a member yet, <a
href="member.php"> Click here</a> to become a member now';
  }?>
</td>
<?php include("footer.php");?>
</body>
</html>


On Tue, Dec 15, 2009 at 10:09 AM, Bastien Koert <[email protected]> wrote:

>  On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan <[email protected]> wrote:
> > Hi,
> >
> > I have 2 pages on php, the first page has a small form to accept a
> > membership number from the user, which checks for membership number in
> the
> > DB, if the membership no does not exist, gives an error saying 'you are
> not
> > a member click here to become a member now', this bit works fine.
> >
> > The problem is the following bit 'if the user is a member, i want the
> user
> > to be directed to another page.
> >
> > this is what i did to get the result since header("Location:....") wont
> > work, as already the form has been printed on the page.
> >
> > echo'<META HTTP-EQUIV="refresh" content="0;URL=member.php">'; but the
> > problem is that this takes couple of seconds, till then the page is very
> > much visible which doesnt look good.
> >
> > Any help on this is much appreciated.
> >
> > Thanks,
> > Vinay.
> >
>
> What about holding the form in the buffer, and then dealing with the
> buffer before sending the form?
>
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.