Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

questions about logins

Status
Not open for further replies.

mettodog

Vendor
Jul 11, 2000
94
US
Hey everyone. Im new to php, and mysql and i have a few questions.
1. On sites like tek-tips, you can easily create a new user. When a new user is created, is a new mysql user created? And, does it use root to create the new user?

2.what is a good online tutorial for php/mysql?

3.Can anyone point me to a tutorial/script that will allow me to do simple php/mysql login to a site?
 
Mettodog:

Sites that have users and the ability to login, such as tek-tips, usually have an extensive database behind the site. MySQL is a good choice.

Now on to your questions.

1. When a new user is created, the database that tek-tips uses is updated, adding a new row, i.e., if there was an id field, an username field, and a password field, the id field would be incremented by one and username and password fields would be updated with the new username and password. Now, the next time that the user logs in with his username and password, a script searches the database to check to see if the user exists, if so, allows them to enter.

2. There are thousands of online tutorials for php/mysql interaction. Try there is a wonderful FAQ for the PHP forum here that tells you how to connect to a mysql database.

3. Here is a simple login script that I wrote:

[tt]
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("messages",$conn);
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$getval = mysql_query($query);
if(mysql_num_rows($getval) > 0) {
echo &quot;<html><head><title>signed in</title>\n&quot;;
$password = md5($password);
echo &quot;<meta http-equiv=\&quot;Refresh\&quot; content=\&quot;1; URL=lobby.php?username=$username&amp;password=$password\&quot;>\n&quot;;
echo &quot;</head>\n&quot;;
echo &quot;welcome<br>\n&quot;;
} else {
echo &quot;We are sorry. You do not appear to be in our database. Click <a href=\&quot;index.php\&quot;>here</a> to sign up</a>\n&quot;;
}

[/tt]

Most of it probably won't make sense until you learn about MySQL and PHP.

Hope this helps,

-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top