|
-
Mar 29th, 2005, 10:46 AM
#1
Thread Starter
Hyperactive Member
logon page with or without mysql
hi, i have installed php onto my IIS 6 server (windows server 2003) and i now have mysql installed on it. i would like to make a logon page in php that can use mysql because i now have it installed on my server. how can i do this. i am still learning php at the moment.
thanks, dandono
Last edited by dandono; Apr 6th, 2005 at 07:54 AM.
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 29th, 2005, 11:01 AM
#2
Re: logon page without mysql
It is possible to use MS Access but I would not recommend it, as it does not function well as a database server. There are two ways you could achieve this:
- If you are using PHP 5 then you can make use of the SqlLite extension. This is a lite weight database engine which has been built into PHP.
- Keep a list of user names/passwords in a CSV file on the server.
There is a link in my signature to a tutorial on installing MySql and PHP so I would advise you give it a go if you want to use a proper database server.
-
Mar 29th, 2005, 02:22 PM
#3
Fanatic Member
Re: logon page without mysql
Or you could just read and write from a plain text file...
It's good enough if you're just doing this for a small project with only a few users and don't have too high demands on security...
Just make sure you store the text file in a directory not accessible from the internet and that you encrypt atleast the passwords. (you should do that in a regular database as well...)
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Mar 30th, 2005, 04:54 AM
#4
Hyperactive Member
Re: logon page without mysql
Hi,
Why not use mysql ? If you have mysql then use it..it would be more safer, faster and friendlier.
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Mar 30th, 2005, 07:39 AM
#5
Thread Starter
Hyperactive Member
Re: logon page without mysql
im downloading mysql from the website not. how can i make a login page using php and mysql. also when it connects to mysql can it use the server name that the page is hosted on so if the page was something like http://somehost/logon.php then it will use the server somehost and so on.
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 30th, 2005, 07:44 AM
#6
Hyperactive Member
Re: logon page without mysql
One simple php/mysql based login script ...stand alone with form:
PHP Code:
<?php
$dbhost = "localhost";
$dbname = "dbname";
$dbuser = "dbuser";
$dbpass = "dbpass";
$conn = mysql_connect($dbhost, $dbname, $dbpass) or die(mysql_error());
$db = mysql_select_db($dbname, $conn) or die(mysql_error());
session_start();
if (isset($_POST["login"]))
{
$q1 = "SELECT * FROM users LIMIT 1";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
$pass = 0;
if($_POST["username"] == $a1["username"])
{
$pass++;
}
if($_POST["password"] == $a1["password"])
{
$pass++;
}
if ($pass == 2)
{
$_SESSION["isAdmin"] = "admin";
header ("Location: manage.php");
exit();
}
else
{
$pass = 0;
echo "Invalid username / password.<br><br>\n";
}
}
?>
<center>
<form method="post" action="login.php">
Username:<br>
<input type="text" name="username" value="<?=$_POST["username"]?>"><br>
Password:<br>
<input type="password" name="password" value="<?=$_POST["password"]?>"><br>
<br>
<input type="submit" value="Login" name="login">
</form>
</center>
Hope this helps.
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Mar 30th, 2005, 09:41 AM
#7
Thread Starter
Hyperactive Member
Re: logon page without mysql
i tried your code and i got the folowing error:
Fatal error: Call to undefined function mysql_connect() in D:\Inetpub\XPROOT\login.php on line 7
how can i get this to work. how do i use MySQL on a windows server. i have downlaoded and installed MySQL onto my windows server but i do not know how to set up my first database. how do i do that.
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 30th, 2005, 09:53 AM
#8
Re: logon page without mysql
 Originally Posted by visualAd
There is a link in my signature to a tutorial on installing MySql and PHP so I would advise you give it a go if you want to use a proper database server. 
____?
-
Mar 30th, 2005, 12:37 PM
#9
Thread Starter
Hyperactive Member
Re: logon page without mysql
i ran that and it returned:
ERROR 2017 <HY000>: Can't open named pipe to host: . pipe: MySQL <2>
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 30th, 2005, 12:51 PM
#10
Hyperactive Member
Re: logon page without mysql
Hi,
If you got error on line 7 it means you have not set something right like: db_host etc.
if you're using iis, mysql and php then it will be
host = "localhost"
username = the db you create in mysql
password = leave it blank
dbname = the db you create in mysql
try this and let me know if it works..but you will get error again when you run the script becuase you have not setupeed the table..
thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Mar 30th, 2005, 12:56 PM
#11
Re: logon page without mysql
If you foollwoed the MySql setup in the tutorial you'll need to set the host $host = '.' as this forces connection through a named pipe.
-
Mar 30th, 2005, 01:04 PM
#12
Thread Starter
Hyperactive Member
Re: logon page without mysql
how should i set up mysql if i wanted it to allow connections from the internet and network?
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 30th, 2005, 01:09 PM
#13
Hyperactive Member
Re: logon page without mysql
Hi
just put the ip in db_host where mysql is running
if its on a system on network has ip of 192.168.1.5 then use 192.168.1.5
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Mar 30th, 2005, 01:22 PM
#14
Thread Starter
Hyperactive Member
Re: logon page without mysql
ok i think i have got mysql set up properly now. how can i get the login.php doc to work with it. i have changes the $dbhost to 192.168.0.1 to connect to it on my network but i get an error. i have tried it on the server and my workstation but same error. the error is:
Fatal error: Call to undefined function mysql_connect() in D:\Inetpub\XPROOT\login.php on line 7. i am able to create databases and delete them now but only from the server.
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 31st, 2005, 01:42 AM
#15
Hyperactive Member
Re: logon page without mysql
Hi,
Have you changed the other values like dbname etc. ? Also can i know how you created the database ? Did you set a password for it ? Also how many people you want to authenticate using this if its just 1 user then it will be better not to use mysql but if its more than 1 then u go for mysql else just make a simple config file and incldue it in the login script and
Thanks.
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Apr 2nd, 2005, 07:55 AM
#16
Thread Starter
Hyperactive Member
Re: logon page without mysql
i set up my first database by using the command prompt (cmd.exe) and entered "mysql" and then "CREATE DATABASE [db1];"
i think at most it would be 10 people at a time but i dont know how popular my site is at school so it might be more.i set a password for the ROOT user if that is what you meen.my server will be dws05.ath.cx (the link in my sig is the website i would like to use)
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 2nd, 2005, 08:49 AM
#17
Hyperactive Member
Re: logon page without mysql
Hi,
You create a new database like this just start mysql in command prompt and then copy paste the following code:
Code:
CREATE DATABASE users;
use users;
CREATE TABLE `users` (
`id` mediumint(9) NOT NULL auto_increment,
`username` varchar(15) default NULL,
`password` varchar(15) default NULL,
`email` varchar(255) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1;
This will create a db named users and a table within that db named users which has username, password and email field.
Hope this helps.
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Apr 2nd, 2005, 07:44 PM
#18
Thread Starter
Hyperactive Member
Re: logon page without mysql
ok i done what you said now how do i configure login.php to work with it?
how does this bit of code work?
$dbhost = "192.168.0.1";
$dbname = "user";
$dbuser = "dbuser";
$dbpass = "dbpass";
i run the php on a workstation so dbhost would be 192.168.0.1 but what would dbuser and dbpass be? i stil get an error. the error is:
Fatal error: Call to undefined function mysql_connect() in D:\Inetpub\XPROOT\login.php on line 7.
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 01:13 AM
#19
Hyperactive Member
Re: logon page without mysql
Hi,
I think there would be no password and the username would be "users" and dbname would be "users" also. Try this and let me know if it works. Leave the password blank.
Thanks!
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Apr 3rd, 2005, 05:43 AM
#20
Re: logon page without mysql
 Originally Posted by dandono
i run the php on a workstation so dbhost would be 192.168.0.1 but what would dbuser and dbpass be? i stil get an error. the error is:
Fatal error: Call to undefined function mysql_connect() in D:\Inetpub\XPROOT\login.php on line 7.
That error is caused when you havn't got the MySql extension enabled or the MySql libraries are not present on your sustem.
If you want the MySql libraries without installing MySql you'll need to download the ZIp version of PHP and copy the file libmysql.dll to C:\winnt\
-
Apr 3rd, 2005, 06:22 AM
#21
Thread Starter
Hyperactive Member
Re: logon page without mysql
what if i have allready installed MySQL for windows? how do i enable the MySQL extension?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 06:29 AM
#22
Re: logon page without mysql
Copy the libmysql.dll file which should be in the bin directory of the MySql installation directory to C:\winnt\, then uncomment the lin in php.ini extension=php_mysql.dll.
-
Apr 3rd, 2005, 07:06 AM
#23
Thread Starter
Hyperactive Member
Re: logon page without mysql
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 07:12 AM
#24
Thread Starter
Hyperactive Member
Re: logon page without mysql
found it in C:\WINDOWS\.
do i need to change the name of the file to php_mysql.dll?
i tried changing the name and then i went to login.php and i got an error on the server: Invalid Library(maybe not a php library)'php_mysql.dll'
Last edited by dandono; Apr 3rd, 2005 at 07:55 AM.
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 11:37 AM
#25
Re: logon page without mysql
You need to edit the php.ini file like I described in the above post. You need two files to turn on the MySql extension. libmysql.dll and php_mysql.dll and you also need to edit the php.ini file to turn on the MySql extension.
Find the line:
;extension = php_mysql.dll
And remove the semi colon so it looks like this:
extension = php_mysql.dll
-
Apr 3rd, 2005, 12:49 PM
#26
Thread Starter
Hyperactive Member
Re: logon page without mysql
do you have a copy of php_mysql.dll because i dont have it on my system.
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 12:51 PM
#27
Re: logon page without mysql
 Originally Posted by visualAd
If you want the MySql libraries without installing MySql you'll need to download the ZIp version of PHP and copy the file libmysql.dll to C:\winnt\
-
Apr 3rd, 2005, 01:15 PM
#28
Thread Starter
Hyperactive Member
Re: logon page without mysql
i done that but on the server it had a message box saying "PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. i have copied libmysql.dll to C:\WINDOWS\ and changed php.ini. do i need to do anything else for it to work?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 01:26 PM
#29
Re: logon page without mysql
Do you have the file php_mysql.dll?
If so put a copy in C:\winnt\ or C:\php\
-
Apr 3rd, 2005, 01:30 PM
#30
Thread Starter
Hyperactive Member
Re: logon page without mysql
i have libmysql.dll but i do not have php_mysql.dll
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 01:35 PM
#31
Re: logon page without mysql
It should be in the ext directory if you downloaded the zip version of PHP.
-
Apr 3rd, 2005, 02:02 PM
#32
Thread Starter
Hyperactive Member
Re: logon page without mysql
i cant find it. can you send me your copy of the file please?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 08:21 PM
#33
Thread Starter
Hyperactive Member
Re: logon page without mysql
ok i have got the right file and done what you said but i got this on login.php
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'users'@'host.ddodn.net' (using password: NO) in D:\Inetpub\XPROOT\login.php on line 7
Access denied for user 'users'@'host.ddodn.net' (using password: NO)
what do i need to change in mysql?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 3rd, 2005, 08:52 PM
#34
Thread Starter
Hyperactive Member
Re: logon page without mysql
ok i have got the right file and done what you said but i got this on login.php
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'users'@'host.ddodn.net' (using password: NO) in D:\Inetpub\XPROOT\login.php on line 7
Access denied for user 'users'@'host.ddodn.net' (using password: NO)
what do i need to change in mysql?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 4th, 2005, 04:26 AM
#35
Re: logon page without mysql
You need to grant the use priviledges in MySql. It can be done like this:
Code:
USE mysql;
GRANT ALL ON dbname.* TO 'username'@'host' IDENTIFIED BY 'password';
-
Apr 4th, 2005, 04:35 PM
#36
Thread Starter
Hyperactive Member
Re: logon page without mysql
when i run the command for creating the database and the tabel it appears with two arrows that look like this
-> ->
what do i do when that happens?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 5th, 2005, 02:15 AM
#37
Hyperactive Member
Re: logon page without mysql
Hi,
If you have IIS and MS Access then why just not use that instead of using PHP and MySQL ???
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Apr 5th, 2005, 03:56 AM
#38
Re: logon page without mysql
 Originally Posted by AvisSoft
If you have IIS and MS Access then why just not use that instead of using PHP and MySQL ??
Because MS Access is terrible as a database server. Once you have more than a couple of connections the whole thing has a tendancy of getting itself scrambled and crashing.
Dan - I do not understand your question. Are you referring to the command line client 'MySql', where you type the queries?
-
Apr 5th, 2005, 04:02 AM
#39
Hyperactive Member
Re: logon page without mysql
Hi visualAd,
Yes you're but dandono says that he earlier wanted it without mysql so if wihtout mysql it is then it would have been text files and we all know that MS Access is far better than text file
And also if IIS and MSAccess is already there then why waste resources on php and mysql...just using the IIS & MSAccess will save him time and resources.
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Apr 5th, 2005, 04:15 AM
#40
Re: logon page without mysql
 Originally Posted by AvisSoft
Yes you're but dandono says that he earlier wanted it without mysql so if wihtout mysql it is then it would have been text files and we all know that MS Access is far better than text file
Access alone uses alot more resources then both PHP and MySql put together. So in my opinion text files are better . Whats more, if he is using PHP 5 then he doesn't even need MySql, he can just use the built in Sql module SqlLite.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|