[PHP-DB] Redirect upon successful form submission

2009-12-15 Thread Vinay Kannan
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.


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

2009-12-15 Thread Bastien Koert
On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan viny...@gmail.com 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

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



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

2009-12-15 Thread Vinay Kannan
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_rows0)
  {
echo'META HTTP-EQUIV=refresh content=0;URL=member.php';

  }

  else
  {

 $not_member=0;
   }


}
 ?
td width=420 class=whitebg
BR /
h3 align=leftREFERENCE 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
tdlabel for=membernoMembership Number/label/td
tdinput type=text name=member_no class=myinput //td/tr
trtdnbsp;/td/tr
trtdinput type=submit name=submit value= OK ! //td
tdinput type=reset name=cancel value= Cancel  //td/tr
trtdinput 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 phps...@gmail.com wrote:

  On Tue, Dec 15, 2009 at 12:48 PM, Vinay Kannan viny...@gmail.com 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



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

2009-12-15 Thread 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 viny...@gmail.com 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?


  



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



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

2009-12-15 Thread Vinay Kannan
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 c...@okto.tv 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 viny...@gmail.com 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?






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




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

2009-12-15 Thread Bastien Koert
On Tue, Dec 15, 2009 at 1:25 PM, Vinay Kannan viny...@gmail.com 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 c...@okto.tv 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 viny...@gmail.com 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?





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

?php

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_rows0)   
  {
echo'META HTTP-EQUIV=refresh 
content=0;URL=member.php';

  } 
  else
  { 

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

  }

}//end function processForm

function showForm(){
?
td width=420 class=whitebg
BR /
h3 align=leftREFERENCE 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
tdlabel for=membernoMembership Number/label/td
tdinput type=text name=member_no class=myinput 
//td/tr
trtdnbsp;/td/tr
trtdinput type=submit name=submit value= OK ! //td
tdinput type=reset name=cancel value= Cancel  
//td/tr
trtdinput type=hidden name=trigger value=6 
//td/tr
/td
?php include(footer.php);?
/table
/form
/body
/html


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



Re: [PHP-DB] Hello

2009-12-15 Thread Chris

Karl DeSaulniers wrote:

What does this do exactly?
Documentation was a bit fuzzy for me.
Is it needed at all times to protect with?


Per the docs:

prepends backslashes to the following characters: \x00, \n, \r, \, ',  
and \x1a.


So anything that has a null character, a newline (windows/linux/mac), 
single and double quotes and \x1a (not sure what that is) is escaped and 
ready to be put in a query.


If you don't quote those characters someone could put one of those 
characters in a query and cause problems - starting off with an invalid 
query but possibly ending up worse.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP-DB] Hello

2009-12-15 Thread Karl DeSaulniers

So what's the difference with that and addslashes() ?

Karl

Sent from losPhone

On Dec 15, 2009, at 3:50 PM, Chris dmag...@gmail.com wrote:


Karl DeSaulniers wrote:

What does this do exactly?
Documentation was a bit fuzzy for me.
Is it needed at all times to protect with?


Per the docs:

prepends backslashes to the following characters: \x00, \n, \r, \,  
',  and \x1a.


So anything that has a null character, a newline (windows/linux/ 
mac), single and double quotes and \x1a (not sure what that is) is  
escaped and ready to be put in a query.


If you don't quote those characters someone could put one of those  
characters in a query and cause problems - starting off with an  
invalid query but possibly ending up worse.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



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



Re: [PHP-DB] Hello

2009-12-15 Thread Chris


addslashes doesn't take encoding's into account.

http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string

goes into some details.

Karl DeSaulniers wrote:

So what's the difference with that and addslashes() ?

Karl

Sent from losPhone

On Dec 15, 2009, at 3:50 PM, Chris dmag...@gmail.com wrote:


Karl DeSaulniers wrote:

What does this do exactly?
Documentation was a bit fuzzy for me.
Is it needed at all times to protect with?


Per the docs:

prepends backslashes to the following characters: \x00, \n, \r, \, ', 
 and \x1a.


So anything that has a null character, a newline (windows/linux/mac), 
single and double quotes and \x1a (not sure what that is) is escaped 
and ready to be put in a query.


If you don't quote those characters someone could put one of those 
characters in a query and cause problems - starting off with an 
invalid query but possibly ending up worse.


--
Postgresql  php tutorials
http://www.designmagick.com/


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






--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP-DB] Random pick

2009-12-15 Thread David McGlone
On Monday 14 December 2009 21:44:24 Chris wrote:
 Chris wrote:
  David McGlone wrote:
  On Monday 14 December 2009 21:02:37 Chris wrote:
  David McGlone wrote:
  Hi everyone,
 
  I've been lurking in the shadows on the list for quite some time and
  now
  I'm in need of a little info or advise.
 
  I'm looking for a way to grab a record out of a database on a
  certain day
  each month and I'm wondering if this can be accomplished with just a
  mysql query or would I need to use PHP also?
 
  A mysql query would do it but you'd use something to talk to mysql and
  process the results (whether it's php, perl, python, ruby etc depends
  on your other requirements).
 
  What I'm trying to do is to have a record picked from the database at
  random on the 1st of every month and display it on the page. Here is
  some code I have been working with:
 
  $query = SELECT DATEADD(mm, DATEDIFF(mm,0,getdate()), 0);
  $result = @mysql_query($query);
  if (!$result){
 
  $query = SELECT * FROM monthlyPooch ORDER BY RAND() LIMIT 1;
  $result = @mysql_query($query);
 
  while ($row = mysql_fetch_array($result)){
  echo $row[poochName] ;
  echo $row[Birthdate];
 
  }
  }
 
  You can check the day of the month in php then do your other query:
 
  $today = date('j');
 
 See http://php.net/date for date formats and what they return.
 
  if ($today !== 1) {
echo Today isn't the first. No need to continue.\n;
exit;
  }
  ..
  random query etc here.
 

Hmmm. This isn't exactly what I'm looking for. What I'm trying to do is get a 
new picture on the 1st of every month and display it for that whole month.

-- 
Blessings
David M.
I have been driven to my knees many times by the overwhelming conviction that 
I had nowhere else to go.

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