Help - Search - Member List - Calendar
Full Version: html to php variable communication
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
ft310
The following code is lifted from an html / php page -- all of the error
checking and other stuff is removed but is there and working in the actual
page.
The issue is moving between html variables and php variables.

I understand html variables holdCounty, holdState and County are not
available to a $_Post function until the Submit function is engaged.

My question: Is there anyway, short of the round trip caused by either
clicking the Submit button or simulating the same action in javascript, to
move the html variables into a php context. It is very hard to justify this
methodology as there are all sorts of User impacts. I can not believe this
is a unique issue and it must have been solved before. I'm a newbee and need
help please as I hate making Users work -- bad form.

$localCounty=$_POST[holdCounty] ;
$localState=$_POST[holdState] ;
$localTest=$_POST[County] ;

$s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ;
if ($localTest=="All")
{
$s_sqlT2 = "" ;
}
else
{
$s_sqlT2="WHERE County='".$localCounty."' AND
State='".$localState."' " ;
}
$s_sqlT3="GROUP BY State, Town ORDER BY State DESC, Town, Area" ;
$s_sqlT0=$s_sqlT1.$s_sqlT2.$s_sqlT3 ;

$dbt=mysql_connect('localhost', 'rhodeisl_ft310', 'billwilson') ;
mysql_select_db('rhodeisl_RISC',$dbt) ;
$resultT=mysql_query($s_sqlT0,$dbt) ;

At the end of this there is no information returned from the database.

NOTES:
A. The full SQL statement is constructed ($s_sqlT0) but the values for
$localCounty and $localState are not there
B. Appropriate information is in the database.
C. It appears the SQL statement works when tested standalone.
D. holdCounty and holdState are html form text boxes and have information
in them
E, County is the result of an html drop down list selection

[Email Removed]

Stefan Rybacki
ft310 wrote:
QUOTE
The following code is lifted from an html / php page -- all of the error
checking and other stuff is removed but is there and working in the actual
page.
The issue is moving between html variables and php variables.

I understand html variables holdCounty, holdState and County are not
available to a $_Post function until the Submit function is engaged.

My question: Is there anyway, short of the round trip caused by either
clicking the Submit button or simulating the same action in javascript, to
move the html variables into a php context. It is very hard to justify this
methodology as there are all sorts of User impacts. I can not believe this
is a unique issue and it must have been solved before. I'm a newbee and need
help please as I hate making Users work -- bad form.

$localCounty=$_POST[holdCounty] ;
$localState=$_POST[holdState] ;
$localTest=$_POST[County] ;

$s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ;
if ($localTest=="All")
{
$s_sqlT2 = "" ;
}
else
{
$s_sqlT2="WHERE County='".$localCounty."' AND
State='".$localState."' " ;
}
$s_sqlT3="GROUP BY State, Town ORDER BY State DESC, Town, Area" ;
$s_sqlT0=$s_sqlT1.$s_sqlT2.$s_sqlT3 ;

$dbt=mysql_connect('localhost', 'rhodeisl_ft310', 'billwilson') ;
mysql_select_db('rhodeisl_RISC',$dbt) ;
$resultT=mysql_query($s_sqlT0,$dbt) ;

At the end of this there is no information returned from the database.

NOTES:
A.    The full SQL statement is constructed ($s_sqlT0) but the values for
$localCounty and $localState are not there
B.    Appropriate information is in the database.
C.    It appears the SQL statement works when tested standalone.
D.    holdCounty and holdState are html form text boxes and have information
in them
E,    County is the result of an html drop down list selection

[Email Removed]


What does print_r($_POST) say?


bonfils
"ft310" <[Email Removed]> wrote:

QUOTE
The following code is lifted from an html / php page -- all of the error
checking and other stuff is removed but is there and working in the actual
page.
The issue is moving between html variables and php variables.

I understand html variables holdCounty, holdState and County are not
available to a $_Post function until the Submit function is engaged.

My question: Is there anyway, short of the round trip caused by either
clicking the Submit button or simulating the same action in javascript, to
move the html variables into a php context. It is very hard to justify
this
methodology as there are all sorts of User impacts. I can not believe this
is a unique issue and it must have been solved before. I'm a newbee and
need
help please as I hate making Users work -- bad form.

$localCounty=$_POST[holdCounty] ;
$localState=$_POST[holdState] ;
$localTest=$_POST[County] ;

I'd say you should write these assignments as
$localCounty=$_POST['holdCounty']; etc.
Without quotes the names would appear to refer to constants. I suppose that
is not the case?

--
bonfils
http://kim.bonfils.com

George King
"ft310" <[Email Removed]> wrote in message
news:YR9Be.52$[Email Removed]...
QUOTE
The following code is lifted from an html / php page -- all of the error
checking and other stuff is removed but is there and working in the actual
page.
The issue is moving between html variables and php variables.

I understand html variables holdCounty, holdState and County are not
available to a $_Post function until the Submit function is engaged.

My question: Is there anyway, short of the round trip caused by either
clicking the Submit button or simulating the same action in javascript, to
move the html variables into a php context. It is very hard to justify
this
methodology as there are all sorts of User impacts. I can not believe this
is a unique issue and it must have been solved before. I'm a newbee and
need
help please as I hate making Users work -- bad form.

$localCounty=$_POST[holdCounty] ;
$localState=$_POST[holdState] ;
$localTest=$_POST[County] ;

$s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ;
if ($localTest=="All")
{
$s_sqlT2 = "" ;
}
else
{
$s_sqlT2="WHERE County='".$localCounty."' AND
State='".$localState."' " ;
}
$s_sqlT3="GROUP BY State, Town ORDER BY State DESC, Town, Area" ;
$s_sqlT0=$s_sqlT1.$s_sqlT2.$s_sqlT3 ;

$dbt=mysql_connect('localhost', 'rhodeisl_ft310', 'billwilson') ;
mysql_select_db('rhodeisl_RISC',$dbt) ;
$resultT=mysql_query($s_sqlT0,$dbt) ;

At the end of this there is no information returned from the database.

NOTES:
A.    The full SQL statement is constructed ($s_sqlT0) but the values for
$localCounty and $localState are not there
B.    Appropriate information is in the database.
C.    It appears the SQL statement works when tested standalone.
D.    holdCounty and holdState are html form text boxes and have
information
in them
E,    County is the result of an html drop down list selection

[Email Removed]



Remember that the web is a stateless environment - your server sent the page
as requested, and will have no knowledge of anything else related to that
particular visitor until that visitor sends in another request - in your
case, with information filled out in the form. No click/submit - no
information to the server.

George

Tony
ft310 wrote:

QUOTE
The following code is lifted from an html / php page -- all of the error
checking and other stuff is removed but is there and working in the actual
page.


Are you sure about that? See below.


QUOTE
The issue is moving between html variables and php variables.

I understand html variables holdCounty, holdState and County are not
available to a $_Post function until the Submit function is engaged.

My question: Is there anyway, short of the round trip caused by either
clicking the Submit button or simulating the same action in javascript, to
move the html variables into a php context. It is very hard to justify this
methodology as there are all sorts of User impacts. I can not believe this
is a unique issue and it must have been solved before. I'm a newbee and need
help please as I hate making Users work -- bad form.

$localCounty=$_POST[holdCounty] ;
$localState=$_POST[holdState] ;
$localTest=$_POST[County] ;



btw - and as already suggested, use:
$localCounty=$_POST['holdCounty'];
(single quotes)


QUOTE

$s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ;
if ($localTest=="All")
{
$s_sqlT2 = "" ;
}
else
{
$s_sqlT2="WHERE County='".$localCounty."' AND
State='".$localState."' " ;
}
$s_sqlT3="GROUP BY State, Town ORDER BY State DESC, Town, Area" ;
$s_sqlT0=$s_sqlT1.$s_sqlT2.$s_sqlT3 ;




You have just performed a query to the database above, but only now are
you about to connect to the server ???




QUOTE
$dbt=mysql_connect('localhost', 'rhodeisl_ft310', 'billwilson') ;
mysql_select_db('rhodeisl_RISC',$dbt) ;
$resultT=mysql_query($s_sqlT0,$dbt) ;

At the end of this there is no information returned from the database.


Not surprised really.

You need to connect to the MySQL server and then select the database,
before you can do *anything* with it.

Google for mysql tutorial or start with the documentation at
http://www.mysql.com/

Hilarion
QUOTE
$s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ;
if ($localTest=="All")
{
$s_sqlT2 = "" ;
}
else
{
$s_sqlT2="WHERE County='".$localCounty."' AND
State='".$localState."' " ;
}
$s_sqlT3="GROUP BY State, Town ORDER BY State DESC, Town, Area" ;
$s_sqlT0=$s_sqlT1.$s_sqlT2.$s_sqlT3 ;




You have just performed a query to the database above, but only now are
you about to connect to the server ???

Nope. He did not perform any query. He just concatenated some texts which
happen to be the query text (which is used later AFTER connecting to SQL
and selecting DB).


QUOTE
$dbt=mysql_connect('localhost', 'rhodeisl_ft310', 'billwilson') ;
mysql_select_db('rhodeisl_RISC',$dbt) ;
$resultT=mysql_query($s_sqlT0,$dbt) ;

At the end of this there is no information returned from the database.

Not surprised really.

You need to connect to the MySQL server and then select the database,
before you can do *anything* with it.

As above.


QUOTE
Google for mysql tutorial or start with the documentation at
http://www.mysql.com/

This can be useful.


Hilarion


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.