Professional Web Applications Themes

Beginners problem - PHP Development

Hi, I'm just beginning PHP programming. I have installed Apache 2.0.48 and PHP 4.3.3. The installation went well. Then I was trying a little example. HTML page: <html> <head> <title>test</title> </head> <body> <form action="test.php" method=POST> First Name: <input type=text name=firstname size=30 MAXLENGTH=150> <input type=submit value="Send"> </form> </body> </html> and the PHP script "test.php": <?php echo "First Name = "; echo $firstname; echo "."; ?> When I insert "Rolf" into the textfield and hit the "Send" button I get the response: First Name = . Nothing else. I thought that the variable $firstname is set to the string I inserted into ...

  1. #1

    Default Beginners problem

    Hi,

    I'm just beginning PHP programming. I have installed Apache 2.0.48 and
    PHP 4.3.3. The installation went well. Then I was trying a little example.

    HTML page:

    <html>
    <head>
    <title>test</title>
    </head>

    <body>

    <form action="test.php" method=POST>
    First Name: <input type=text name=firstname size=30
    MAXLENGTH=150>
    <input type=submit value="Send">
    </form>

    </body>
    </html>

    and the PHP script "test.php":

    <?php
    echo "First Name = ";
    echo $firstname;
    echo ".";
    ?>

    When I insert "Rolf" into the textfield and hit the "Send" button I get
    the response:

    First Name = .

    Nothing else. I thought that the variable $firstname is set to the
    string I inserted into the text field. Did I do anything wrong or could
    there be a problem with apache or php? I would be very appreciative for
    help on this problem.

    Regards

    Rolf Wester

    P.S.: When using method GET the form calls:
    [url]http://localhost:8080/test.php?firstname=Rolf[/url]
    The Response is the same as before.


    Rolf Wester Guest

  2. #2

    Default Re: Beginners problem

    Rolf Wester wrote:
    > Hi,
    >
    > I'm just beginning PHP programming. I have installed Apache 2.0.48 and
    > PHP 4.3.3. The installation went well. Then I was trying a little example.
    >
    > HTML page:
    >
    > <html>
    > <head>
    > <title>test</title>
    > </head>
    >
    > <body>
    >
    > <form action="test.php" method=POST>
    > First Name: <input type=text name=firstname size=30
    > MAXLENGTH=150>
    > <input type=submit value="Send">
    > </form>
    >
    > </body>
    > </html>
    >
    > and the PHP script "test.php":
    >
    > <?php
    > echo "First Name = ";
    > echo $firstname;
    > echo ".";
    > ?>
    >
    > When I insert "Rolf" into the textfield and hit the "Send" button I get
    > the response:
    >
    > First Name = .
    >
    > Nothing else. I thought that the variable $firstname is set to the
    > string I inserted into the text field. Did I do anything wrong or could
    > there be a problem with apache or php? I would be very appreciative for
    > help on this problem.
    >
    > Regards
    >
    > Rolf Wester
    >
    > P.S.: When using method GET the form calls:
    > [url]http://localhost:8080/test.php?firstname=Rolf[/url]
    > The Response is the same as before.
    >
    Very common problem this. You have register_globals turned off, it's the
    default in recent releases of php.

    replace
    echo $firstname;
    with
    echo $_POST['firstname'];
    and all will be well

    Kevin Thorpe Guest

  3. #3

    Default Re: Beginners problem

    Kevin Thorpe wrote:
    >
    > Very common problem this. You have register_globals turned off, it's the
    > default in recent releases of php.
    >
    > replace
    > echo $firstname;
    > with
    > echo $_POST['firstname'];
    > and all will be well
    >
    Thanks a lot. It works now. Is it possible to turn register_globals on
    and if so how can I do it?

    Regards

    Rolf Wester

    Rolf Wester Guest

  4. #4

    Default Re: Beginners problem

    <sanyafan.astral.ntu-kpi.kiev.ua> wrote in message
    news:20031031190557.11a9cf70.sanyafan.astral.ntu-kpi.kiev.ua...
    > On Fri, 31 Oct 2003 17:53:45 +0100
    > Rolf Wester <westerilt.fraunhofer.de> wrote:
    >
    > > Hi,
    > >
    > > I'm just beginning PHP programming. I have installed Apache 2.0.48 and
    > > PHP 4.3.3. The installation went well. Then I was trying a little
    example.
    > >
    > > HTML page:
    > >
    > > <html>
    > > <head>
    > > <title>test</title>
    > > </head>
    > >
    > > <body>
    > >
    > > <form action="test.php" method=POST>
    > > First Name: <input type=text name=firstname size=30
    > > MAXLENGTH=150>
    > > <input type=submit value="Send">
    > > </form>
    > >
    > > </body>
    > > </html>
    > >
    > > and the PHP script "test.php":
    > >
    > > <?php
    > > echo "First Name = ";
    > > echo $firstname;
    > > echo ".";
    > > ?>
    > /////////////////////////////////////////////////////////
    > in php.ini register_globals = On or use $HTTP_POST_VARS["firstname"]
    > ////////////////////////////////////////////////////////
    >
    > >
    > > When I insert "Rolf" into the textfield and hit the "Send" button I get
    > > the response:
    > >
    > > First Name = .
    > >
    > > Nothing else. I thought that the variable $firstname is set to the
    > > string I inserted into the text field. Did I do anything wrong or could
    > > there be a problem with apache or php? I would be very appreciative for
    > > help on this problem.
    > >
    > > Regards
    > >
    > > Rolf Wester
    > >
    > > P.S.: When using method GET the form calls:
    > > [url]http://localhost:8080/test.php?firstname=Rolf[/url]
    > > The Response is the same as before.
    > >
    > >


    I wouldn't do that if I were you.
    It's best to get into good habits from the start.
    Globals on is a security risk.

    Regards
    Richard Grove

    [url]http://redeyemedia.co.uk[/url]
    [url]http://shopbuilder.org[/url]
    Become a Shop Builder re-seller:
    [url]http://affiliatewindow.com/affiliates/merchantdetails.php?mid=611[/url]


    Richard Grove Guest

  5. #5

    Default Re: Beginners problem

    Hi,

    thanks to all for your help. I would like to turn on register_globals
    mainly for the purpose of trying some sample-scripts downloaded from
    somewhere that rely on this. I will use the more secure option
    $_POST['**'] for my own scripts.

    Regards

    Rolf Wester

    Rolf Wester Guest

  6. #6

    Default Re: Beginners problem

    On Fri, 31 Oct 2003 17:53:45 +0100
    Rolf Wester <westerilt.fraunhofer.de> wrote:
    > Hi,
    >
    > I'm just beginning PHP programming. I have installed Apache 2.0.48 and
    > PHP 4.3.3. The installation went well. Then I was trying a little example.
    >
    > HTML page:
    >
    > <html>
    > <head>
    > <title>test</title>
    > </head>
    >
    > <body>
    >
    > <form action="test.php" method=POST>
    > First Name: <input type=text name=firstname size=30
    > MAXLENGTH=150>
    > <input type=submit value="Send">
    > </form>
    >
    > </body>
    > </html>
    >
    > and the PHP script "test.php":
    >
    > <?php
    > echo "First Name = ";
    > echo $firstname;
    > echo ".";
    > ?>
    /////////////////////////////////////////////////////////
    in php.ini register_globals = On or use $HTTP_POST_VARS["firstname"]
    ////////////////////////////////////////////////////////
    >
    > When I insert "Rolf" into the textfield and hit the "Send" button I get
    > the response:
    >
    > First Name = .
    >
    > Nothing else. I thought that the variable $firstname is set to the
    > string I inserted into the text field. Did I do anything wrong or could
    > there be a problem with apache or php? I would be very appreciative for
    > help on this problem.
    >
    > Regards
    >
    > Rolf Wester
    >
    > P.S.: When using method GET the form calls:
    > [url]http://localhost:8080/test.php?firstname=Rolf[/url]
    > The Response is the same as before.
    >
    >
    sanya@fan.astral.ntu-kpi.kiev.ua Guest

Similar Threads

  1. Beginners help
    By virtualflow in forum Macromedia Flash Flashcom
    Replies: 14
    Last Post: March 7th, 05:59 AM
  2. 3d beginners question
    By wtrbrs in forum Macromedia Director 3D
    Replies: 3
    Last Post: September 7th, 08:18 PM
  3. ActiveX for beginners..........
    By Mintyman in forum Macromedia Director Basics
    Replies: 1
    Last Post: December 18th, 12:56 AM
  4. Beginners question
    By Jon Sinclair in forum Macromedia Flash
    Replies: 2
    Last Post: September 27th, 12:46 AM

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