SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error With Forms

    Hello,
    I tried creating a basic html form with two text boxes and a submit button. On click of the submit button the values of the buttons are supposed to be passed to the php,however, It is not working.

    Here is the code for the html form:

    <html>
    <head>
    <title> Query String Link Example </title>
    </head>
    <body>
    <form action="welcome2.php" method="get">
    First Name:
    <input type="text" name="firstname" /><br />
    Last Name: <input type="text" name="lastname" /><br />
    <input type="submit" value="GO" />
    </form>
    </body>
    </html>

    Here is the code for the php form

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <?php
    echo("Welcome $firstname $lastname");
    >?
    </body>
    </html>

    PLEASE NOTE: When the php form is loaded I can only see the"Welcome" form the echo statement.

    I am using IIS 4..........ANY IDEAS.

    Chris

  2. #2
    Weird Little Girl Desdelena's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change the form method from GET to POST.

  3. #3
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most likely, the register_globals option is turned off in your php.ini. This is the new default setting in PHP 4, and it's more secure.

    You should access form data using either the $HTTP_POST_VARS or $HTTP_GET_VARS associative arrays (version < 4.1) or $_POST and $_GET associative arrays (version > 4.1).

    Thus,
    PHP Code:
    <?php
    $firstname 
    $_GET['firstname'];
    $lastname $_GET['lastname'];
    echo(
    "Welcome $firstname $lastname");
    >?

  4. #4
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do I always have to use the "Get" as per the code below

    <?php
    $firstname = $_GET['firstname'];
    $lastname = $_GET['lastname'];
    echo("Welcome $firstname $lastname");
    >?

    or can I just set the php.ini file?

  5. #5
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's better for security in general to have register_globals switched off. It does mean a little extra coding but security will not be compromised as a result.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM Email NEW! Carrier Pigeon


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
  •