SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 38 of 38

Thread: $php_self

  1. #26
    SitePoint Member
    Join Date
    Mar 2003
    Location
    london
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    wow erm just got in, cheers for the help guys n00bs and pros all ur help is welcome and ill try them in a sec and keep ya posted! ur efforts are seriosuly appreciated by this n00b.

  2. #27
    SitePoint Member
    Join Date
    Mar 2003
    Location
    london
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no luck sorry [img]images/smilies/frown.gif[/img] Rahven ur one was exact same as mine, erm larry ur one i dont know wat the hel happened but it copied entire text to the url when i clicked link. if ya guys wanna go try here:

    http://neomatrix.homeip.net i created a quick temp adress for u lot to see what the problem is [img]images/smilies/smile.gif[/img]

    look closely as what happens to the url when u click the go button and so on and the newpage.php only has this coding in it :
    <?php
    echo ("Hello, $_GET[name]")
    ?>

    i never used commas in the previous examples and they worked.
    Last edited by NeoMatrix; Mar 31, 2003 at 08:43.

  3. #28
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NeoMatrix
    erm larry ur one i dont know wat the hel happened but it copied entire text to the url when i clicked link.
    i copied my exact code and it works great. when i looked at your page earlier, you still have stuff messed up, because PHP code was visible in the source. and you still have &_SERVER in there etc.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  4. #29
    SitePoint Member
    Join Date
    Mar 2003
    Location
    london
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the probem is with the text from the book as it does this with the &_SERVER etc part coz basically it adds the ?name= blah blah and then i will be able to click the link but instead it adds a:

    /%3c/?name= which is why i think the link is picking up the error as there is no newpage.php to link to coz of that %3c...what is that? how i get rid of it? code is same as on page 1

    if i can get that sorted out maybe i can fix part two which is that when i click the link word it produces this in the url. it goes to the page but not displaying the variable after pre-set word: Hello,

    ));%20]http://localhost/newpage.php?name=<?php%20echo(urlencode($_GET[name]));%20?>
    Last edited by NeoMatrix; Apr 1, 2003 at 10:12.

  5. #30
    SitePoint Enthusiast Rahven's Avatar
    Join Date
    Mar 2003
    Location
    In the barrel with the other monkeys.
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NeoMatrix-

    This is the source code for samplepage.php in chapter 3 of Kevin's book. This is what you want. Please write yourself a phpinfo script and find out if register_globals is on or off, and whether short_open_tags is on or off.

    In case you don't know, php info script:
    PHP Code:
    <?php phpInfo();?>
    Just load that file into your browser after saving it in your development server. It will print out a list of the variables that can be configured on your php.ini file. This script will work with register_globals off, but if you are working from the first edition book, the code in the book will not look the same as the code here. Primarily, $PHP_SELF becomes $_SERVER['PHP_SELF'] Please check the code below against the code you wrote yourself. Make sure that in your code, every semi-colon, apostrophe, and quotation mark is in the same place as the source code below. The code below works on My RedHat 8 machine with Apache 2.0.40, MySQL 4, and PHP 4.2.2, I assume it works on just about anything with MySQL 3.23 and up, and PHP 4 and up.


    HTML Code:
    <html>
    
    <head>
    
    <title> Sample Page </title>
    
    </head>
    
    <body>
    
    PHP Code:
    <?php if ( !isset($_GET['name']) ): ?>



      <!-- No name has been provided, so we

           prompt the user for one.         -->



      <form action="<?=$_SERVER['PHP_SELF']?>" method="get">

      Please enter your name: <input type="text" name="name" />

      <input type="submit" value="GO" />

      </form>



    <?php else: ?>



      <p>Your name: <?=$_GET['name']?></p>



      <p>This paragraph contains a <a href="newpage.php?name=<?=urlencode($_GET['name'])?>">link</a> that passes the name variable on to the next document.</p>



    <?php endif; ?>
    HTML Code:
    </body>
    
    </html>

  6. #31
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DR_LaRRY_PEpPeR
    not affect the result, no. i just use commas to seperate multiple parameters to echo (it saves 1 byte by not putting a space if front of the , like with . ) since it's supposed to be faster than concatenating multiple strings with . and i think it looks neater.

    note: you can't use commas with echo if you use parentheses: echo('foo', 'bar') won't work.

    Just wondering, would this work for includes too then, not just echos?
    Mike
    It's not who I am underneath, but what I do that defines me.

  7. #32
    SitePoint Member
    Join Date
    Mar 2003
    Location
    london
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope still the same thing even iwth ur code, i also tried tweaking ur code and stil same thing.. i stated before globals were off and short tage are on. its that damn /%3c/ or whatever is causing the problem otherwise i know itll work

    rahven i ran ur script in like zend debugger etc and i got no errors. ur code is right but somewhere it prints "/%3c/" which is why the ?name=nfnfbf isnt recognised..plus ur php info tags did nothing.
    Last edited by NeoMatrix; Apr 2, 2003 at 09:59.

  8. #33
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    phpinfo() did nothing? Are you sure you have PHP installed?
    Mike
    It's not who I am underneath, but what I do that defines me.

  9. #34
    SitePoint Enthusiast Rahven's Avatar
    Join Date
    Mar 2003
    Location
    In the barrel with the other monkeys.
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NeoMatrix
    rahven i ran ur script in like zend debugger etc and i got no errors. ur code is right but somewhere it prints "/%3c/" which is why the ?name=nfnfbf isnt recognised..plus ur php info tags did nothing.
    Well I realy don't know what to tell you. I'm really inexperienced and not the best person to try to help you with this problem, but if you got no output... wait... you need to create a regular html framework and put phpInfo() between body tags.. if you didn't do that, then no, you won't get anything. If it is in a regular html page and you still get no output, I would think that there's something wrong with your install of PHP.

    What OS are you running? Did you install Apache, MySQL and PHP yourself? If you're on M$, are you using IIS?

    As far as this lil chunk of script you're having trouble with, at what point are you having trouble, exactly? Are you getting the form to insert your name? If you are getting that form, after you enter your name are you getting a page that says "blah blah blah 'name'. This link wil take you... blah blah"? If you are then it is working, the link that appears under the sentence with the name you gave is to a page called "newpage.php" is there a page called "newpage.php" in your directory? There isn't unless you made one.

    What I'm saying is that that link will return a 404 error if you click it, the whole point of that script was to show you how to grab a variable from a form and pass it through that form. Beyond that I'm clueless.

  10. #35
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rahven
    ... wait... you need to create a regular html framework and put phpInfo() between body tags.. if you didn't do that, then no, you won't get anything.
    Not true. A page containing only <?php phpinfo() ?> will return all the PHP parameters and settings - you don't need HTML structure around it.
    Ian Anderson
    www.siteguru.co.uk

  11. #36
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in fact, phpinfo(); outputs <html> <body> even a doctype.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  12. #37
    SitePoint Enthusiast Rahven's Avatar
    Join Date
    Mar 2003
    Location
    In the barrel with the other monkeys.
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru
    Not true. A page containing only <?php phpinfo() ?> will return all the PHP parameters and settings - you don't need HTML structure around it.
    Quote Originally Posted by cyborg from dh
    in fact, phpinfo(); outputs <html> <body> even a doctype.

    I learn something new everyday... one of these days I'll even learn to keep my mouth shut, heh.

  13. #38
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by naramation
    Just wondering, would this work for includes too then, not just echos?
    try it and see... the error. so no, echo is the only thing you can do it with since it's a language construct.


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
  •