dongqiu3709 2011-04-25 04:35
浏览 50

php post方法不起作用

Can someone assist me with figuring out why my form isn't doing anything/not functioning. I am very new to programming so bear with me if you can. When the submit button is pressed nothing at happens. I want it to recall something based off of what is entered in the text field. (nothing in particular, just trying to experiement/learn.)

This is in my html file:

<form action="process.php" method="post">
<input type="text" name="fname" valude="pdate"/>

this is in my process.php file:

$fdate = $_POST['fname'];

setcookie ("user", $fdate, time() +60*60*24*365);

if (isset($_COOKIE['user'])){
        var_dump ($_COOKIE);
}
else{
        header('fname:index.html');
}

Thanks

  • 写回答

2条回答 默认 最新

  • donglv6960 2011-04-25 04:39
    关注

    This code Worked For Me :

    Test.php

    < ?php
    if( isset( $_POST['fname'] ) )
    {
        setcookie ("user", $_POST['fname'], time() +60*60*24*365);
    }
    
    if( isset( $_COOKIE['user'] ) )
    {
        echo 'COOKIE IS SET';
    } else
    {
        echo 'COOKIE NOT SET';
    }
    ?> 
    <form action="" method="post">
        <input type="text" name="fname" value="pdate" />
        <button type="submit">Go</button>
    </form>
    
    评论

报告相同问题?