SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Location
    San Antonio, TX
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Question on the necessity of $_POST

    I just switched hosting companies and most of my scripts aren't working now.
    For years now when I've made a form like:

    HTML Code:
    <p>First Name: <input name="firstname" type="text"></p>
    <p>Last Name: <input name="lastname" type="text"></p>
    and when submitted, I would simply call the fields on the page in this fashion:

    Code:
    echo $firstname;
    echo $lastname;
    This has worked fine on my two previous hosting companies. But this past weekend I switched to a new hosting company and it doesn't work. I'm having to go through my scripts and change it to something like:

    Code:
    echo $_POST['firstname'];
    echo $_POST['lastname'];
    Being self taught, I'm assuming I just missed something early on in my PHP life and now it has come back to bite me in the ****. But I wanted to ask about it so that I can have a better understanding of it all.

    Is this a simple difference in how PHP is configured?
    If so, is it something I could change in the php.ini file?
    If both options work, is one inherently better than the other?

    Thanks.

  2. #2
    SitePoint Evangelist Andrewaclt's Avatar
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    register_globals was set from the default on to off in something like php 4.2. It's a good idea to keep it this way. If you *REALLLY* want to change it is in the php.ini but it's a security issue to enable it. My memory is a little hazy but before 4.1 these features did not exit, instead if register globals was implicitly set off you had to use something like HTTP_SERVER_VARS.

    Anyway, I would update your code and leave things like they are as far as the php.ini goes

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not Bad :d

  4. #4
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Andrewaclt View Post
    I would update your code and leave things like they are as far as the php.ini goes
    Seconded.
    PHP questions? RTFM
    MySQL questions? RTFM

  5. #5
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may also want to double check your <?php ?> php tags. If you use the shorthand <? ?> code to signify php code(Which is not preferred) this could also cause your scripts to not work.
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers


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
  •