Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default Am i missing somthing here...

    Code:
    <?php
    ob_start;
    if($_SERVER['REQUEST_METHOD']=="POST")(
    setcookie("name", "$_POST['name'];", time()+3600");
    else { ?>
    <form name="name" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
    Name: 
    <input name="name" type="text">
    <br> 
    <input type="submit" name="Submit" value="Submit"> 
    </form>
    <?php
    }
    ?>
    Missing somthing, cant quite put my finger on it...
    James


    Connected to reality through a proxy server.

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    You're missing an "}" :\

    PHP Code:
    <?php
    ob_start
    ;
    if(
    $_SERVER['REQUEST_METHOD']=="POST")(
    setcookie("name""$_POST['name'];"time()+3600");
    } else { ?>
    <form name="
    name" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
    Name: 
    <input name="name" type="text">
    <br> 
    <input type="submit" name="Submit" value="Submit"> 
    </form>
    <?php
    }
    ?>

  3. #3
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default

    Ah i see now, thanks, +REP

    Still doesnt work.
    Last edited by Mr Macro; 18-04-2007 at 04:10 PM.
    James


    Connected to reality through a proxy server.

  4. #4
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default

    PLEASE IGNORE
    James


    Connected to reality through a proxy server.

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Mr Macro View Post
    Code:
    <?php
    ob_start;
    if($_SERVER['REQUEST_METHOD']=="POST") {
    setcookie("name", $_POST['name'], time()+3600);
    } else { 
    ?>
    <form name="name" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
    Name: 
    <input name="name" type="text">
    <br> 
    <input type="submit" name="Submit" value="Submit"> 
    </form>
    <?php
    }
    ?>
    Missing somthing, cant quite put my finger on it...
    You were useing ( instead of { and missed the second one completely. you also had an unopened " being closed, and a ; after a variable within a function.
    Last edited by Mentor; 18-04-2007 at 04:15 PM.

  6. #6
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default

    Thats my half assed style of coding for you.Thanks
    James


    Connected to reality through a proxy server.

  7. #7
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    It's likely that by using the superglobal 'PHP_SELF', you're exposing yourself to a XSS vulnerability. Before outputting it, you should run it through htmlentities.
    kinda quit.

  8. #8
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default

    Thanks for the concern, but its just on my local macheane.I'm just doing some PHP practice.
    James


    Connected to reality through a proxy server.

  9. #9
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by nets View Post
    It's likely that by using the superglobal 'PHP_SELF', you're exposing yourself to a XSS vulnerability. Before outputting it, you should run it through htmlentities.
    o.0 in that instance i dont see how it would be any use, sure you could include the page and get it to think the includeing page was where the form should be send? but you could just as easly rewrite the entire form and send it where ever you wanted anyway o.0

  10. #10
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    It's possible to add characters (for instance, HTML/JavaScript) onto the end of a URL, which the superglobal 'PHP_SELF' will contain; hence why you shouldn't output it without running it through htmlentities.
    Last edited by nets; 18-04-2007 at 11:45 PM.
    kinda quit.

Posting Permissions

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