cactus Posted March 19, 2011 Share Posted March 19, 2011 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 Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/ Share on other sites More sharing options...
cactus Posted March 19, 2011 Author Share Posted March 19, 2011 Sorry I meant i'm new to this function not forums lol Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/#findComment-1189485 Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 You don't define $form_token anywhere in the code, you define $_SESSION['form_token']. Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/#findComment-1189492 Share on other sites More sharing options...
cactus Posted March 19, 2011 Author Share Posted March 19, 2011 Thanks Pikachu2000. Could you tell me how I would change this to not get the error anymore? Thanks again Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/#findComment-1189501 Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 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']; Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/#findComment-1189506 Share on other sites More sharing options...
cactus Posted March 19, 2011 Author Share Posted March 19, 2011 Thank you i'll try that Link to comment https://forums.phpfreaks.com/topic/231087-undefined-variable-form_token/#findComment-1189516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.