Jump to content

Recommended Posts

I completed my login script consist of two php.

 

Index.php

 

<html>
<body>
<form id="form1" name="form1" method="post" action="login.php">
  <div align="center">
    <p>Username : 
      <input type="text" name="username" />
  </p>
    <p>Password : 
      <input type="text" name="password" />
    </p>
    <p>
       <input name="Submit" type="submit" id="Submit" value="Login" />
</p>
  </div>
</form>
</body>
</html>

 

Login.php

<?php

$user = "admin";
$pass = "admin";

if ($_POST['username'] == $user and $_POST['password'] == $pass) {
echo 'Successfully login.';
} else {
  echo 'Invalid username/password.';
}

?>

 

I want to make a login script that use session and after I login it will shows me the control panel. Thanks  :D

 

 

Link to comment
https://forums.phpfreaks.com/topic/194637-making-a-login-script-with-a-session/
Share on other sites

I completed my login script consist of two php.

 

Index.php

 

<html>
<body>
<form id="form1" name="form1" method="post" action="login.php">
  <div align="center">
    <p>Username : 
      <input type="text" name="username" />
  </p>
    <p>Password : 
      <input type="text" name="password" />
    </p>
    <p>
       <input name="Submit" type="submit" id="Submit" value="Login" />
</p>
  </div>
</form>
</body>
</html>

 

Login.php

<?php

$user = "admin";
$pass = "admin";

if ($_POST['username'] == $user and $_POST['password'] == $pass) {
echo 'Successfully login.';
} else {
  echo 'Invalid username/password.';
}

?>

 

I want to make a login script that use session and after I login it will shows me the control panel. Thanks  :D

 

There are many of these pre-made scripts out there. I would advise using one of those instead of re-inventing the wheel unless your circumstances necessitate doing something different.

Basically you will need a database to hold a username and password. You will want a way to encode the password. You can look into the md5 function for this. You will also need to learn how to use sessions. Or you can do a simple google search for php login script and find one you like :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.