Re: [PHP-DB] Re: Undefined index and variables

2003-01-15 Thread Fred Wright
Of course, but that would solve the problem I have, albeit it would look
more elegant. Have tried everything except the solution which I cannot find,
see the zip file earlier up the list from Fred Wright

"Ben Joyce" <[EMAIL PROTECTED]> wrote in message
DF1220D4F915D4119C6B00306E00103E0252EDB7@IDS10004">news:DF1220D4F915D4119C6B00306E00103E0252EDB7@IDS10004...
> Couldn't you use the 'for each' method on $_POST instead?
>
>  .b
>
> > -Original Message-
> > From: Hutchins, Richard [mailto:[EMAIL PROTECTED]]
> > Sent: 15 January 2003 16:44
> > To: 'Fred Wright'; [EMAIL PROTECTED]
> > Subject: RE: [PHP-DB] Re: Undefined index and variables
> >
> >
> > Fred,
> >
> > I don't have much time today, but here is my initial
> > assessment of what might be going wrong with your page:
> >
> > You display add.php which draws a form for data.
> > You submit that form to add.php (itself).
> > The form redraws inside the page.
> > You get errors when add.php looks for data in the
> > $HTTP_POST_VARS array because the page is fresh and that
> > array is empty.
> >
> > Problem is that there is no code to handle the data that was
> > entered in the first place. Once you hit submit, the add.php
> > page is (re)drawn in its original state - with no values in
> > the fields. Therefore, when the $_POST['varname'] statement
> > looks in $HTTP_POST_VARS, there's nothing to display so you
> > get the Undefined Index errors. It's almost like refreshing the page.
> >
> > My advice would be to separate the code for the data entry
> > and data handling parts of your project into independent
> > scripts. Use add.php to collect the data then send the data
> > to a php script called handleAdd.php that gets the name/value
> > pairs and submits them to the database. After submitting the
> > data to the database in handleAdd.php, forward the user back
> > to another page (add.php again, if you want) where they can
> > get some kind of confirmation the data was entered.
> >
> > A further recommendation would be to provide the list with
> > the code you gave to me so maybe somebody else with a little
> > more free time might be able to assist you further. Sorry I
> > couldn't provide any more help.
> >
> > Rich
> >
> > > -Original Message-
> > > From: Fred Wright [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, January 15, 2003 12:21 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP-DB] Re: Undefined index and variables
> > >
> > >
> > >  > > //This is lines 22 and 23 of Add.php
> > > require("common.php") ;
> > > GenerateHTMLForm();
> > > $smt2= $_POST['Ref'];  //line 22
> > > $smt3=$_POST['Chassis']; //line 23
> > >
> > > The form below is in common.php
> > >
> > > function GenerateHTMLForm() {
> > >
> > > printf("");
> > >
> > > printf("");
> > >
> > > printf("Reference:");
> > > printf("");
> > >
> > > printf("Chassis:");
> > > printf("");
> > > printf("");  printf("");
> > >  printf("" );
> > > }
> > >
> > > "Fred Wright" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > Hi to all
> > > > Being new to PHP I am naturally experiencing some minor problems.
> > > >
> > > > I have a form which processes Ref and Chassis data, when I
> > > load Add.php
> > > > which does work but on loading get errors
> > > >
> > > > Notice: Undefined index: Ref in C:\Xitami\webpages\add.php
> > > on line 22
> > > > Notice: Undefined index: Chassis in
> > > C:\Xitami\webpages\add.php on line 23
> > > > How do I get rid of these undefined errors? Could anyone
> > > advise please.
> > > > Regards
> > > > Fred
> > > >
> > > > printf("");
> > > >
> > > > printf("");
> > > >
> > > > printf("Reference:");
> > > >
> > > > printf("");
> > > >
> > > > printf("Chassis:");
> > > > printf("");
> > > >
> > > > printf("");
> > > >
> > > > printf("");
> > > >
> > > > printf("" );
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > 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
> >
>



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




RE: [PHP-DB] Re: Undefined index and variables

2003-01-15 Thread Ben Joyce
Couldn't you use the 'for each' method on $_POST instead?

 .b

> -Original Message-
> From: Hutchins, Richard [mailto:[EMAIL PROTECTED]] 
> Sent: 15 January 2003 16:44
> To: 'Fred Wright'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Re: Undefined index and variables
> 
> 
> Fred,
> 
> I don't have much time today, but here is my initial 
> assessment of what might be going wrong with your page:
> 
> You display add.php which draws a form for data.
> You submit that form to add.php (itself).
> The form redraws inside the page.
> You get errors when add.php looks for data in the 
> $HTTP_POST_VARS array because the page is fresh and that 
> array is empty.
> 
> Problem is that there is no code to handle the data that was 
> entered in the first place. Once you hit submit, the add.php 
> page is (re)drawn in its original state - with no values in 
> the fields. Therefore, when the $_POST['varname'] statement 
> looks in $HTTP_POST_VARS, there's nothing to display so you 
> get the Undefined Index errors. It's almost like refreshing the page.
> 
> My advice would be to separate the code for the data entry 
> and data handling parts of your project into independent 
> scripts. Use add.php to collect the data then send the data 
> to a php script called handleAdd.php that gets the name/value 
> pairs and submits them to the database. After submitting the 
> data to the database in handleAdd.php, forward the user back 
> to another page (add.php again, if you want) where they can 
> get some kind of confirmation the data was entered.
> 
> A further recommendation would be to provide the list with 
> the code you gave to me so maybe somebody else with a little 
> more free time might be able to assist you further. Sorry I 
> couldn't provide any more help.
> 
> Rich
> 
> > -Original Message-
> > From: Fred Wright [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 15, 2003 12:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] Re: Undefined index and variables
> > 
> > 
> >  > //This is lines 22 and 23 of Add.php
> > require("common.php") ;
> > GenerateHTMLForm();
> > $smt2= $_POST['Ref'];  //line 22
> > $smt3=$_POST['Chassis']; //line 23
> > 
> > The form below is in common.php
> > 
> > function GenerateHTMLForm() {
> > 
> > printf("");
> > 
> > printf("");
> > 
> > printf("Reference:");
> > printf("");
> > 
> > printf("Chassis:");
> > printf("");  
> > printf("");  printf("");
> >  printf("" );
> > }
> > 
> > "Fred Wright" <[EMAIL PROTECTED]> wrote in message 
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Hi to all
> > > Being new to PHP I am naturally experiencing some minor problems.
> > >
> > > I have a form which processes Ref and Chassis data, when I
> > load Add.php
> > > which does work but on loading get errors
> > >
> > > Notice: Undefined index: Ref in C:\Xitami\webpages\add.php
> > on line 22
> > > Notice: Undefined index: Chassis in
> > C:\Xitami\webpages\add.php on line 23
> > > How do I get rid of these undefined errors? Could anyone
> > advise please.
> > > Regards
> > > Fred
> > >
> > > printf("");
> > >
> > > printf("");
> > >
> > > printf("Reference:");
> > >
> > > printf("");
> > >
> > > printf("Chassis:");
> > > printf("");
> > >
> > > printf("");
> > >
> > > printf("");
> > >
> > > printf("" );
> > >
> > >
> > 
> > 
> > 
> > --
> > 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
> 


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




RE: [PHP-DB] Re: Undefined index and variables

2003-01-15 Thread Hutchins, Richard
Fred,

I don't have much time today, but here is my initial assessment of what
might be going wrong with your page:

You display add.php which draws a form for data.
You submit that form to add.php (itself).
The form redraws inside the page.
You get errors when add.php looks for data in the $HTTP_POST_VARS array
because the page is fresh and that array is empty.

Problem is that there is no code to handle the data that was entered in the
first place. Once you hit submit, the add.php page is (re)drawn in its
original state - with no values in the fields. Therefore, when the
$_POST['varname'] statement looks in $HTTP_POST_VARS, there's nothing to
display so you get the Undefined Index errors. It's almost like refreshing
the page.

My advice would be to separate the code for the data entry and data handling
parts of your project into independent scripts. Use add.php to collect the
data then send the data to a php script called handleAdd.php that gets the
name/value pairs and submits them to the database. After submitting the data
to the database in handleAdd.php, forward the user back to another page
(add.php again, if you want) where they can get some kind of confirmation
the data was entered.

A further recommendation would be to provide the list with the code you gave
to me so maybe somebody else with a little more free time might be able to
assist you further. Sorry I couldn't provide any more help.

Rich

> -Original Message-
> From: Fred Wright [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 12:21 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Re: Undefined index and variables
> 
> 
>  //This is lines 22 and 23 of Add.php
> require("common.php") ;
> GenerateHTMLForm();
> $smt2= $_POST['Ref'];  //line 22
> $smt3=$_POST['Chassis']; //line 23
> 
> The form below is in common.php
> 
> function GenerateHTMLForm() {
> 
> printf("");
> 
> printf("");
> 
> printf("Reference:");
> printf("");
> 
> printf("Chassis:");
> printf("");
>  printf("");
>  printf("");
>  printf("" );
> }
> 
> "Fred Wright" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hi to all
> > Being new to PHP I am naturally experiencing some minor problems.
> >
> > I have a form which processes Ref and Chassis data, when I 
> load Add.php
> > which does work but on loading get errors
> >
> > Notice: Undefined index: Ref in C:\Xitami\webpages\add.php 
> on line 22
> > Notice: Undefined index: Chassis in 
> C:\Xitami\webpages\add.php on line 23
> > How do I get rid of these undefined errors? Could anyone 
> advise please.
> > Regards
> > Fred
> >
> > printf("");
> >
> > printf("");
> >
> > printf("Reference:");
> >
> > printf("");
> >
> > printf("Chassis:");
> > printf("");
> >
> > printf("");
> >
> > printf("");
> >
> > printf("" );
> >
> >
> 
> 
> 
> -- 
> 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