How to make connection to a DB throu login form?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

How to make connection to a DB throu login form?

Post by johnnyxp »

cause i am new to PHP i need to give me some code that creats a fiels "username" and a field "password" then submits those entries to a page called e.g db.php and where the ......

Code: Select all

<?php 
define("HOST", "localhost");
define("USER", "put the username var here from the field username");
define("PASS", "put the password here fro the field password");
define("DB", "HRC");
?>
plz i need a solution...i know you are fast Help me tnx!!!! :cry:

?>
Last edited by johnnyxp on Fri Nov 07, 2003 5:29 pm, edited 1 time in total.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

umm.. im not really sure what you mean.. but..

Code: Select all

<html>
<body>
<form action="db.php" method="post" name="form1">
Username: <input type="text" name="user"><br>
Password: <input type="text" name="pass"><br>
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>

like that..?
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

Variables??

Post by johnnyxp »

well my friend that is the form ok, but in the db.php file how to tell it that the username and password are comming from the form!???
i mean where is the Variables??? :?:
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

<?php
$username = $_POST['username'];
$password = $_POST['password'];
?>
you mean this?
or do you mean you want to connect to a database useing ur defined vars?

Code: Select all

<?php
mysql_connection(HOST, USER, PASSWORD);
mysql_select_db(DB);
?>
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

Post by johnnyxp »

i want to connect to the db by giving every time different usern & pass throught the form! i will taste your scode or do you have something ready?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Re: How to make connection to a DB throu login form?

Post by d3ad1ysp0rk »

johnnyxp wrote:cause i am new to PHP

no offense, but that's a really bad reason.

[google]php tutorials[/google]

start there..
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

Post by johnnyxp »

thats not a solution start reading tutorials and found my solution aftra hours when someone can give it to me in seconds, so that i will finish my homework in time, and then i will read the tutorial for better understanding!
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

Post by johnnyxp »

any one?

Code: Select all

<?php 
define("HOST", "localhost");
define("USER", "put the username var here from the field username");
define("PASS", "put the password here fro the field password");
define("DB", "HRC");
?>
Last edited by johnnyxp on Fri Nov 07, 2003 5:30 pm, edited 1 time in total.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

you want to learn, we are happy to teach for free, you want to get code, we (most of us) charge by the hour.
johnnyxp
Forum Newbie
Posts: 6
Joined: Fri Nov 07, 2003 3:41 pm

Post by johnnyxp »

plz people you were niewbies too!!! i thought that php follows the rule "human knowledge belongs to the world" and thats for FREE!!!

oh just forget it if you dont want to help.
tnx for your "free" time.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

do your homework tonight, read part of the tutorial tonight and part tommorow

and bam, you learnt how to do it on your own
Post Reply