Jump to content

Undefined variable: form_token


cactus

Recommended Posts

Hi everyone,

 

I'm new to forums so I apologise if I don't explain myself properly. I am following a tutorial to make a blog system. I got to the log i portion and have encountered an error.

The error reads:

 

Notice: Undefined variable: form_token in C:\wamp\www\Blog\login.php on line 17 Call Stack #TimeMemoryFunctionLocation 10.0009367584{main}( )..\login.php:0 " />

 

The code is as follows:

<?php 
        /*** start the session ***/
        session_start();

        /*** include the header file ***/
        include 'includes/header.php';

        /*** set a form token ***/
        $_SESSION['form_token'] = md5(rand(time(), true));
?>

<h1>Blog Login</h1>
<p>
Please supply your username and password.
</p>
<form action="login_submit.php" method="post">
<input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />
<dl>
<dt>Username</dt>
<dd><input type="text" name="blog_user_name" /></dd>

<dt>Password</dt>
<dd><input type="password" name="blog_user_password" /></dd>
<dd><input type="submit" value="Login" /></dd>
</dl>
</form>

 

I really hope someone can help me as I have never used form token before? Please.

Thanks  :P

Link to comment
https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/
Share on other sites

My guess is that the tutorial you're following is outdated and using code that relies on register_globals being set to on (which is a bad idea). You'll need to either use the $_SESSION var directly, or assign its value: $form_token = $_SESSION['form_token'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.