SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    cheshire
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script doesn't work!

    Can anyone tell me why the script below doesn't work. The script does the first bit OK in that when a visitor opens the page for the first time there is no value for $name so the visitor gets a form asking for their name. On submitting, their name should go off to another page(a nearly identical page) which as its getting a value for $name should display some text and the link - however, it doesn't behave as it should, its like its not recieving $name because it displays the html form asking for a name?- although I can see in the URL address location that it has recieved the value for $name. What is going on please, its driving me nuts. Oh yes, nearly forgot, earlier versions I did seemed to pass on not just a name but also the string 'urlencode(Rob Smith)'
    Thanks
    David

    <HTML>
    <HEAD>
    <TITLE> Sample Page </TITLE>
    </HEAD>
    <BODY>
    <?php
    if ( isset($name) )
    {

    print(" <P>Your name is: $name </P> \n");
    $name = urlencode ($name);
    print("<P>This paragraph contains a <A HREF= \"secondpage.php?name = $name \">link</A>\n");
    print(" that passes the name variable on to the next document.</P>\n");
    }

    else
    {
    print(" <!-- No name has been provided, so we
    prompt the user for one. -->");

    print(" <FORM ACTION = $PHP_SELF METHOD = GET><br>\n");
    print(" Please enter your name: <INPUT TYPE = TEXT NAME = \"name\"><br>\n");
    print(" <INPUT TYPE = SUBMIT VALUE = \"GO\">\n");
    print(" </FORM><br>\n");
    print("Wellcome to our website $name!");
    }
    ?>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is register_globals enabled?
    /* Chris Lambert - chris@php.net
    WhiteCrown Networks, CTO - Web Application Security
    vBulletin, Security Programmer - Instant Community
    */

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you need to take out the spaces here

    PHP Code:
    print("<P>This paragraph contains a <A HREF= \"secondpage.php?name = $name \">link</A>\n"); 

    should be

    PHP Code:
    print("<P>This paragraph contains a <A HREF= \"secondpage.php?name=$name \">link</A>\n"); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like he's not even getting to that part of the script though.
    /* Chris Lambert - chris@php.net
    WhiteCrown Networks, CTO - Web Application Security
    vBulletin, Security Programmer - Instant Community
    */

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    cheshire
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    It was those bloody spaces - problem solved.
    I wouldn't like to admit the time that I wasted
    over that!
    Thanks
    David


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
  •