Redirect upon successful form submission

Redirect upon successful form submission

am 15.12.2009 18:48:09 von Vinay Kannan

--0016e64ee34c39a97a047ac7fef5
Content-Type: text/plain; charset=ISO-8859-1

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

--0016e64ee34c39a97a047ac7fef5--

Re: Redirect upon successful form submission

am 15.12.2009 19:09:18 von Phpster

On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan 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''; 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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Redirect upon successful form submission

am 15.12.2009 19:19:04 von Vinay Kannan

--0016e64c2608d7ad18047ac86c5b
Content-Type: text/plain; charset=ISO-8859-1

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.


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'';

}

else
{

$not_member=0;
}


}
?>



REFERENCE FOR MEMBERSHIP TO INFINITY LEARNERS CLUB



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.












 


if($not_member==0)
{
echo 'Our records indicate that you are not a member yet, href="member.php"> Click here to become a member now';
}?>






On Tue, Dec 15, 2009 at 10:09 AM, Bastien Koert wrote:

> On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan 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''; 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
>

--0016e64c2608d7ad18047ac86c5b--

Re: Redirect upon successful form submission

am 15.12.2009 19:21:44 von Christoph Rosse

you could also validate the form in a seperate php file with no output
and then redirect to the "error" and the "another page" ?


Bastien Koert schrieb:
> On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan 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''; 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?
>
>
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Redirect upon successful form submission

am 15.12.2009 19:25:04 von Vinay Kannan

--0016367b6c3a43ca75047ac8826e
Content-Type: text/plain; charset=ISO-8859-1

Yep, that would work, but then if the user is not a member, then the link to
the membership should be printed on the form that has the validation and not
the one that has the form?

On Tue, Dec 15, 2009 at 10:21 AM, Christoph Rosse wrote:

> you could also validate the form in a seperate php file with no output and
> then redirect to the "error" and the "another page" ?
>
>
> Bastien Koert schrieb:
>
> On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan 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''; 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?
>>
>>
>>
>>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--0016367b6c3a43ca75047ac8826e--

Re: Redirect upon successful form submission

am 15.12.2009 20:31:00 von Phpster

On Tue, Dec 15, 2009 at 1:25 PM, Vinay Kannan wrote:
> Yep, that would work, but then if the user is not a member, then the link to
> the membership should be printed on the form that has the validation and not
> the one that has the form?
>
> On Tue, Dec 15, 2009 at 10:21 AM, Christoph Rosse wrote:
>>
>> you could also validate the form in a seperate php file with no output and
>> then redirect to the "error" and the "another page" ?
>>
>>
>> Bastien Koert schrieb:
>>>
>>> On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan 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''; 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?
>>>
>>>
>>>
>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>

When you look at it like that all together, I find its easier to
functionalize the whole process


include("header.php");
include("lib/funcs.php");


if(isset($_POST['submit'])){
processForm();
}else{
showForm();
}

function processForm(){

$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'';

}
else
{

if($not_member==0)
{
echo 'Our records indicate that you are not a member yet, href="member.php"> Click here to become a member now';
}

}

}//end function processForm

function showForm(){
?>



REFERENCE FOR MEMBERSHIP TO INFINITY LEARNERS CLUB



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.














 






}//end showForm function
?>


This gives way more control over the whole flow

--

Bastien

Cat, the other other white meat

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php