login script using cookies. page does't redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lonely
Forum Newbie
Posts: 2
Joined: Mon Mar 14, 2011 2:10 am

login script using cookies. page does't redirect

Post by lonely »

Hi all,
I am a beginner PHP programmer. when i click on login button. it pass the url "http://localhost/mylibrary/index.php?co ... login=true" instead of redirect to Home.php
config file is included..to conn with mysql. & store pwd in MD5.
1. login form.
<form name="login_form" action="<?php echo $PHP_SELF; ?>?cookie_set=true&login=true" method="post">

2.Index.php
if ($cookie_set==true)
{
if ($login==true)
{
// Making sure the form is not blank
if ($username==true && $password==true)
{
// Setting login cookie
// Encripting the password with MD5
$password = MD5($password);

setcookie("MyLibrary[username]", $username);
setcookie("MyLibrary[password]", $password);
header ("Location: $PHP_SELF?module=home");
exit;
}

plz help me.
Attachments
MyLibrary.zip
(7.39 KiB) Downloaded 36 times
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: login script using cookies. page does't redirect

Post by social_experiment »

Code: Select all

if ($cookie_set==true)
{
if ($login==true)
To access values from the query string use $_GET, i.e $_GET['cookie_set'] & $_GET['login'] (unless you are already doing it.)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
lonely
Forum Newbie
Posts: 2
Joined: Mon Mar 14, 2011 2:10 am

Re: login script using cookies. page does't redirect

Post by lonely »

Thank you very much brother....... :) it was my silly mistake :banghead:
:offtopic:
Post Reply