Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing String with URL Problem?

    im atempting to learn PHP and iv ran into a situation...

    Im running apache web server with php and mySQL...This question has nothing to do with mySQL but....

    I Created a file called welcome.hml and included the following code...

    <html>
    <head>
    <title>Welcome</title>
    </head>

    <body>

    <Font color = "Black">
    <a href="http://localhost/welcome.php?name=Dave"> Hi, I'm Dave!</a>

    </body>

    </html>

    Then i created a filed called welcome.php and included this code...

    <html>
    <head>
    <title>Welcome</title>
    </head>

    <body>

    <?php
    echo( "Welcome to our web site, $name!" );
    ?>

    </body>

    </html>

    and then i goto http://localhost/welcome.html and click on the link and it takes me to welcome.php but heres the problem...

    The output on welcome.php says:
    Welcome to our web site, !

    It doesnt pass the name dave to the page from the URL whats causing that... I got the code straight from a book...

    I know php is working cause i used it witha date function and it worked fine

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Weird... Do you have register_globals turn ON in the php.ini file?

    If not, you'll have to use this:

    <?="Welcome to our web site, ".$_GET['name']."!"?>
    Offtone.com - In the works...

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes their turned on...Im not even sure where to look for the problem... so any input will help thanx

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i put that code you said in and it did work yet globals are turned on

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i wonder...Is the file supposed to be php.ini or php.ini-dist which is what its named....Also when i make changes to i need to restart apache and if so whats the proper way to shut down apache and restart it

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok i renamed the file and now it works... i changed it from php.ini-dist to php.ini....Im not sure where the -dist came from....

    Thanx for your help

  • #7
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Novosibirsk, Russia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    dist means distribution, that&rsquo;s the default template which you are supposed to copy and modify.

    And one advice: leave register_globals off and get a habit of accessing arguments via $_GET and $_POST, this will prevent the situation when you expect a variable to be empty yet someone passes you a value through the query string.

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for the advice...

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Plus more and more hosts will eventually be switching register_globals off so your scripts may fall apart on some new-age host
    Offtone.com - In the works...

  • #10
    New Coder
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But, if you have a html template loading data to show as text depending on say $page:

    index.php?page=home

    then users won't be able to bookmark your pages. Not totally relevant but I think that hosts turning it off in the ini is not very helpful.
    skinme.net / v2.php (design nearly completed)

  • #11
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    index.php?page=home

    will still work for the user, the only difference is that your script will have to do this (just guessing what $page does here)

    include('/home/httpd/include/$_GET[home].php');
    instead of this
    include('/home/httpd/include/$home.php');

    register_globals only changes how we access the varibles nothing else
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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