Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:37:19+00:00 2026-06-09T13:37:19+00:00

I am learning how to use setcookie, however, I couldn’t get following line to

  • 0

I am learning how to use “setcookie”, however, I couldn’t get following line to work,
I have pasted all my codes here, if someone could give me a hand please?
Have no idea the reason.
Many thanks.

  else{ die ("hahahahahahahahahahahahahaha"); }

HTML code

<form method="POST" action="">
<div class="error"><?php echo $error;?></div>
<p></p>
<label>Username: </label><br>
<input type="text" name="username"><br>
<label>Password: </label><br>
<input type="password" name="password"><br>
<input type="checkbox" name="rememberme"> Remember me<br>
<input type="submit" name="submit" value="Login">

PHP CODE

<?
if(isset($_POST['submit'])){
    //get data
    $username = $_POST['username'];
    $password = $_POST['password'];
    $rememberme = isset($_POST['rememberme']);
    echo $rememberme;


    if($username&&$password){
    $login = mysql_query("SELECT * FROM form WHERE username='$username'");

    while ($row = mysql_fetch_assoc($login))
    {
        $db_password = $row['password'];
        if (md5($password)== $db_password)
        {
            $logstatus = TRUE;
            }
        else{
            $logstatus = FALSE; 
            }
        if ($logstatus == TRUE)
        {
            if ($rememberme == "1")
                setcookie("username", $username, time()+600);
            else if ($rememberme == "")
                $_SESSION['username'] = $username;


        echo " I am here";
        }

        else{
           die ("hahahahahahahahahahahahahaha"); //unable to get here
        }
    }

}

    else{
    echo "enter username / password";
    }
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:37:21+00:00Added an answer on June 9, 2026 at 1:37 pm

    Try this code, I haven’t tested it but is should works 🙂

    session_start();//dont forget this :P
    if(isset($_POST['submit'])){
        //get data
        $username = $_POST['username'];
        $password = $_POST['password'];
        $rememberme = isset($_POST['rememberme']);
        echo $rememberme;    
    if($username&&$password){
        $login = mysql_query("SELECT * FROM form WHERE username='$username' AND password='".md5($password)."'");
    
    
            if (mysql_num_rows($login))//if this returns 1 you are logged in
            {
                if ($rememberme == "1")
                    setcookie("username", $username, time()+600);
                else
                    $_SESSION['username'] = $username;
    
    
                    echo " I am here";              
    
            }else{
               die ("Incorrect Username/Password"); //unable to get here
            }
        }
    
    }
    
        else{
        echo "enter username / password";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning to use pointer to copy char array. I have the following code
I'm learning to use xlib and I'm unable to get XChangeProperty() to work for
I am just learning to use Services, and am sort of stuck. I have
I am learning to use mysql for rails apps, and I finally have been
I am learning to use DelgateCommand from Prism.... In my UI, I have my
I'm learning to use the PHP interactive shell, but I'm having trouble with multi-line
I am learning to use sed and have a hypothetical requirement: bash$ cat states
I am learning to use Core Data. I have created a data model etc
I have enjoyed learning to use OpenGL under the context of games programming, and
I am learning to use Processing , and have modified one of the examples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.