English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
0

What is a PHP Login Code.I want to make people log in and they will see their name or data.And they will see their data till they log out.And I want a log out code too.Not the other user.I use Dreamweaver MX.If can you can teach me with dreamweaver.

2007-01-31 17:22:49 · 5 answers · asked by Pesa09 1 in Computers & Internet Programming & Design

5 answers

This can be done by using PHP's session. To start a PHP session the code would be:



Note: this has to be at the very top of the page of code like this:



body content


Then you would have your HTML form in the login page:







You might be worried about security. If you want a secure connection you may want to invest in an SSL certificate. You can get the them very cheap at GoDaddy.com. They will explain how to use them.

Make sure that your form method is POST and not GET. The GET method will make the pass display in the address bar.

You have to match up the password and username with a database. The username and password would be kept in a single database row. You can store other values in that row that you may want returned such as name, last login, etc.

The form's action is "account.php". We must make that page and store it just like you would store any file. But it must have the extension .php

Now we will make the "account.php" page that has a database (MySQL) connection.

------account.php--------
$con = mysql_connect("localhost","dbusername","dbpassword");
// connect to server with the database
if (!$con)
{
die('Could not connect to database ') ;
}
// if connection fails
mysql_select_db("my_db", $con);
// name the DB you want to connect to

$result = mysql_query("SELECT * FROM person");
// command for DB to execute
$numrows=mysql_num_rows($numresults);
// number of results returned for that pass and user

while($row = mysql_fetch_array($result))
if ($numrows == 0)
{
echo "We cannot find a record in our database for that username and password";
}
if ($numrows >= 2)
{
echo " We cannot find a record that has the username and password";
}
if ($numrows == 1)
{
session_start();
echo "You are currently logged in" .$row['name'];
// the .$row['name'] would post the name of the user that is //stored in the database
echo "Would you like to Logout";
}

mysql_close($con); // close connection
?>

Here's what the "logout.php" page would look like.

session_destroy();

echo "You are currently logged out";
?>

Sessions are ended soon as the user leaves the website.

In this case you would start the session later because you must check with the database to see if the password and username exist in the same row. For more information about sessions and databases go to w3schools.com.

http://w3schools.com/php/php_mysql_intro.asp

2007-02-03 11:44:48 · answer #1 · answered by going123sold 2 · 0 0

you're unlikely to get intense high quality and each and all the best factors you want for unfastened. basically ain't going to ensue. perhaps there might nicely be some web site that helps non-commercial websites like yours, yet they are going to be difficult to locate. the positioning has to help the container, the working equipment, the information superhighway server app (Apache, maximum possibly), plus own abode page and Perl a minimum of, plus the database. Plus you favorpersistent area and ftp get admission to? good success.

2016-11-02 00:46:59 · answer #2 · answered by ? 4 · 0 0

This isn't easy at all. PHP is a programming language that takes a long time to understand and code.

What is the easiest way is to use a CMS (Content Management System). The most popular are Joomla and Drupal.

Here are their sites!

http://www.joomla.org
http://www.drupal.org

2007-01-31 17:28:46 · answer #3 · answered by olympikdude 4 · 0 2

You can find your needed many "login" & "logout" script from this link:
http://www.tutorialized.com/search.php?s=log&id=3&page=3

Best of Luck

Simanto

2007-01-31 17:42:29 · answer #4 · answered by cool _ sim 2 · 0 0

You have to use sessions, check out this site it will probably help you
http://www.phpbuddy.com/article.php?id=14

Good luck

2007-01-31 17:27:28 · answer #5 · answered by jessieg14 3 · 0 0

fedest.com, questions and answers