Professional Web Applications Themes

html to php variable communication - PHP Development

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

  1. #1

    Default html to php variable communication

    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

    net


    ft310 Guest

  2. #2

    Default Re: html to php variable communication

    ft310 wrote: 
    What does print_r($_POST) say?
    Stefan Guest

  3. #3

    Default Re: html to php variable communication

    "ft310" <com> wrote:
     

    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


    bonfils Guest

  4. #4

    Default Re: html to php variable communication


    "ft310" <com> wrote in message
    news:YR9Be.52$america.net... 

    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



    George Guest

  5. #5

    Default Re: html to php variable communication

    ft310 wrote:
     


    Are you sure about that? See below.

     



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

     




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



     


    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 doentation at
    http://www.mysql.com/
    Tony Guest

  6. #6

    Default Re: html to php variable communication

    >> $s_sqlT1="SELECT Town, Area, State, County FROM LocationsGB " ; 
    >
    >
    >
    >
    > You have just performed a query to the database above, but only now are
    > you about to connect to the server ???[/ref]

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

     
    >
    > Not surprised really.
    >
    > You need to connect to the MySQL server and then select the database,
    > before you can do *anything* with it.[/ref]

    As above.

     

    This can be useful.


    Hilarion
    Hilarion Guest

Similar Threads

  1. flash and html communication?
    By riverdog05 in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: June 10th, 08:28 AM
  2. 2 sep. movies on one HTML page. communication possible?
    By KaseiSol in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: December 22nd, 01:13 AM
  3. php variable in html
    By Christian in forum PHP Development
    Replies: 7
    Last Post: December 4th, 04:45 PM
  4. Can't output a variable to HTML
    By Phester in forum PHP Development
    Replies: 2
    Last Post: September 21st, 01:46 AM
  5. Replies: 0
    Last Post: July 18th, 01:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139