/    Sign up×
Community /Pin to ProfileBookmark

Redirect log in page

To whom is this concern i have problem with log in page i am trying to redirect page on my index.php page but i couldn’t ,this code i copied from your website.Right here when i going from log in page to success page i getting blank page.

I think is problem here echo “<form action=”?op=login” method=”POST”>”; because when i am trying to preview in browser on the end of the domain i have this ?”?op=login”

<?php
session_start();
// dBase file
include “dbConfig.php”;
if ($_GET[“op”] == “login”)
{
if (!$_
POST[“username”] || !$_POST[“password”])
{
die(“You need to provide a username and password.”);
}
// Create query
$q = “SELECT * FROM `dbUsers`
.”WHERE `username`='”.$_
POST[“username”].”‘ ”
.”AND `password`=PASSWORD(‘”.$_POST[“password”].”‘) ”
.”LIMIT 1″;
// Run query
$r = mysql_query($q);
if ( $obj = @mysql_fetch_object($r) )
{
// Login good, create session variables
$_
SESSION[“valid_id”] = $obj->id;
$_SESSION[“valid_user”] = $_POST[“username”];
$_SESSION[“valid_time”] = time();
// Redirect to member page
Header(“Location: members.php”);
}
else
{
// Login not successful
die(“Sorry, could not log you in. Wrong login information.”);
}
}
else
{
//If all went right the Web form appears and users can log in
echo “<form action=”?op=login” method=”POST”>”;
echo “Username: <input name=”username” size=”15″>”;
echo “Password: <input type=”password” name=”password” size=”8″>”;
echo “<input type=”submit” value=”Login”>”;
echo “</form>”;
}
?>

?

to post a comment
PHP

17 Comments(s)

Copy linkTweet thisAlerts:
@Nicholas_DiazJun 19.2013 — Ya i really wish you would of typed your problem a little better your text is a little confusing. but im gonna try to help. first of all i would not of set this up the way you have it set up.

  • 1. you can use get and post you need to pick one of the other when gathering the information. so if someone is trying to log in with a for and the action is post but then in your authentication process you are using GET its not gonna work right.


  • 2. the reason you see OP=login in the URL is because when you use the GET method it post the information to the URL.


  • So to start with... cause I am not to clear on where the page is directing you when you login. you did not specify that to clearly. it sounds like it is just posing the GET value to the URL. Change the GET to POST and see if that fixes your problem. If not I think we might have to rewrite your script. Ill post one to give you an example.

    I really advise against having forms in pages posting to them selves. for some reason I have noticed a lot of people posting questions where their forms dont show up or behave correctly and when you make the action method in the form point to another page and put the php in that page everything seems to work fine. I am not sure why that is maybe someone with more experience then me would not mind explaining it.

    Please retype your question and be more clear about what your seeing before you execute anything. and then what your seeing after. such as if the page redirects what does the URL say?
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — Ya i really wish you would of typed your problem a little better your text is a little confusing. but im gonna try to help. first of all i would not of set this up the way you have it set up.

  • 1. you can use get and post you need to pick one of the other when gathering the information. so if someone is trying to log in with a for and the action is post but then in your authentication process you are using GET its not gonna work right.


  • 2. the reason you see OP=login in the URL is because when you use the GET method it post the information to the URL.


  • So to start with... cause I am not to clear on where the page is directing you when you login. you did not specify that to clearly. it sounds like it is just posing the GET value to the URL. Change the GET to POST and see if that fixes your problem. If not I think we might have to rewrite your script. Ill post one to give you an example.

    I really advise against having forms in pages posting to them selves. for some reason I have noticed a lot of people posting questions where their forms dont show up or behave correctly and when you make the action method in the form point to another page and put the php in that page everything seems to work fine. I am not sure why that is maybe someone with more experience then me would not mind explaining it.

    Please retype your question and be more clear about what your seeing before you execute anything. and then what your seeing after. such as if the page redirects what does the URL say?[/QUOTE]


















    This is where is orginal code //www.webdeveloper.com/forum/showthread.php?265799-Login-amp-Registration-form-with-profile





    http://www.webdesigngroup1999.com/mysqladmin/register.php this is my register page after i pass register page, i am getting blank page



    www.webdesigngroup1999.com/mysqladmin/login.php after i pass log in page i am getting blank page






    My problem is i made index.page with text and i can redirect to that page.(index.page)
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — This is where is orginal code //www.webdeveloper.com/forum/showthread.php?265799-Login-amp-Registration-form-with-profile





    http://www.webdesigngroup1999.com/mysqladmin/register.php this is my register page after i pass register page, i am getting blank page



    www.webdesigngroup1999.com/mysqladmin/login.php after i pass log in page i am getting blank page






    My problem is i made index.page with text and i can not redirect to that page.(index.page)[/QUOTE]
    [/QUOTE]?
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — ok so when someone logs in you want to send them back to the index page but if there is a session start you want them to have access to hidden information?
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — ok do this...

    I need you to post your index page. your login script. and do it with code tags so its easy for me to read. so type [code ] with out the space and close it with [/code ] two seperate scripts one is the full index page and one is the login script.

    unless they are on the same page if so just post what you have the way you have it in the code tags
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — ok do this...

    I need you to post your index page. your login script. and do it with code tags so its easy for me to read. so type [code ] with out the space and close it with [/code ] two seperate scripts one is the full index page and one is the login script.

    unless they are on the same page if so just post what you have the way you have it in the code tags[/QUOTE]







    This my code log in page
    [code ]

    <?php
    session_start();
    // dBase file
    include "dbConfig.php";
    if ($_GET["op"] == "login")
    {
    if (!$_POST["username"] || !$_POST["password"])
    {
    die("You need to provide a username and password.");
    }
    // Create query
    $q = "SELECT * FROM dbUsers "
    ."WHERE username='".$_POST["username"]."' "
    ."AND password=PASSWORD('".$_POST["password"]."') "
    ."LIMIT 1";
    // Run query
    $r = mysql_query($q);
    if ( $obj = @mysql_fetch_object($r) )
    {
    // Login good, create session variables
    $_SESSION["valid_id"] = $obj->id;
    $_SESSION["valid_user"] = $_POST["username"];
    $_SESSION["valid_time"] = time();
    // Redirect to member page
    Header("Location: members.php");
    }
    else
    {
    // Login not successful
    die("Sorry, could not log you in. Wrong login information.");
    }
    }
    else
    {
    //If all went right the Web form appears and users can log in
    echo "<form action="?op=login" method="POST">";
    echo "Username: <input name="username" size="15">";
    echo "Password: <input type="password" name="password" size="8">";
    echo "<input type="submit" value="Login">";
    echo "</form>";
    }
    ?>

    [/code ]




    This is my index.php page
    [code ]

    <?php ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    testtttttttttttttt
    <body>
    </body>
    </html>



    [/code ]
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — dont put spaces in the code brackets... is this all the code?

    is this your index page?
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — dont put spaces in the code brackets... is this all the code?

    is this your index page?[/QUOTE]




    Yes that is it.
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — i need you to answer my question... so when someone goes to your webpage you want them to immediatly be prompted to login? right? and once they login then they can see the information on the index page? so as of now it would be i go to your site. i log in then it shows me test on the page? is this correct?
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — or do youw ant them to go to members.php? cause you have them going to members.php right now which u have not showed me that file yet
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — did you set up the page members.php?
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — Yes
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — log in and copy your url and paste it in to here for me to see
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — log in and copy your url and paste it in to here for me to see[/QUOTE]

    http://www.webdesigngroup1999.com/mysqladmin/login.php?op=login
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 19.2013 — Ok I can fix this for you but I would have to so do it my way. If you want me to fix it take the site folder export the table in the database and put it in the site folder. Zip it email it to me and ill remake the login and make everything work flush for you by tonight

    Email Address Removed.
    Copy linkTweet thisAlerts:
    @AdoauthorJun 19.2013 — Ok I can fix this for you but I would have to so do it my way. If you want me to fix it take the site folder export the table in the database and put it in the site folder. Zip it email it to me and ill remake the login and make everything work flush for you by tonight

    Email me at [email][email protected][/email][/QUOTE]





    If you want help go on this site

    http://www.webdeveloper.com/forum/showthread.php?265799-Login-amp-Registration-form-with-profile

    The first 5 codes i copied and use to make register and log in form.You can do it same thing copy the code, fix it and then copy here for me,you can use own date base if you want.
    Copy linkTweet thisAlerts:
    @Nicholas_DiazJun 20.2013 — I am not the one who needs help.. you are. and I am willing to help you.
    ×

    Success!

    Help @Ado spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.29,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...