How Can I Work With Cookies In This ?

saqib389saqib389 BeginnerLink Clerk
i have create first page page "login.php" here is username and email

then after submiting form on 2nd page this show another feilds like

'name'.. 'age' location..

after sumbiting 2nd page then on third page there shuld come

login.php values that

"Welcome to "USERNAME value"

and on 3rd page there would b a link of first page.... login.php...

whenever i click on login.php again then ... i shuld not see the Text

feilds........

it shuld come there like you have logged in ... welcome to "username

value"

i hope you get my point

i m unable to do this
plz any one can help me ? as u ppl help me before
i will look forward to hear ur response

SaQib

Comments

  • PythonPython Forum Leader The Royal RAM
    This is basically a user registration script. Take a look at http://www.devdreams.com/tutorials/t/61

    That could then be customized so that the registration process spans across a few pages...

    The Royal Ram

  • saqib389saqib389 Beginner Link Clerk
    no i was asking some thing else.....

    here is the code

    login.php
    
    <html>
    <body>
    <form action=cookie.php method=post>
    Name:<input type=text name=username/><br>
    Email:<input type=text name=email ><br>
    <input type="submit" name="submit" value="Submit me!" />
    </body>
    </html>
    


    cookie.php ---- ( here i m getting error )
    
    <?php
    setcookie("uname",$_POST['username']);
    ?>
    <html> 
    <body> 
    <form action = print.php method="post"> 
    Name:<Br><input name="name" type="text" /><Br> 
    Age:<Br><input name="age" type="text" /><Br> 
    Location:<Br><input name="loc" type="text" /><Br> 
    <input type="submit" name="submit" value="Submit me!" /> 
    </form> 
    </body> 
    </html> 
    
    


    print.php
    <?php
    echo "Hello, ".$_COOKIE['uname'];
    ?> 
    
    

    here i want to display that Hello "Username" Which i have enter on first page. that username shuld store on cookies.... and when i redirect the login.php.. that page should not ask me for username again.. and login.php should display "hi username(sam)"

    plz guide me how to do this..

    SaQib
  • FelixFelix Junior Member Shared Hoster
    Its because you forgot to set an expiration time for your cookie.
    [PHP]
    setcookie("uname", $_POST);
    [/PHP]

    SHOULD BE SOMETHING LIKE:

    [PHP]
    setcookie("uname", $_POST, time() + 72000);
    [/PHP]
Sign In or Register to comment.