Page 1 of 1

Adding members to a database through Forms...

Posted: Fri Apr 26, 2002 11:11 am
by Jim
Call me a n00b if you will (since that's what I am), but I'm wondering if you can add information to tables through forms.

In this case, I'd like to create a member database (you may remember me asking about this about a week ago) that stores the following information:

I'm putting it in a table called pro_members:


First Name
Last Name
Email Address
Password
Password (Make sure they match...)

Eventually, I'd like to add a profile field in which they can add information about themselves. For now, though, I'm not worried about that.

Is there a way to do this using forms? Kinda like the joining thing on evilwalrus.com or even these forums.

Thanks for your help!

Posted: Fri Apr 26, 2002 11:17 am
by epsilon
Use this to insert something into the db, annoucements is the table name, (name) is the row, $name is the name of your textbox.
$query = "INSERT INTO announcements(name) VALUES('$name')";
To make sure the passwords match I would do something like this:
if($pass1 == $pass2)
{
run the insert query
}
else
{
echo ("sorry, the passwords don't match.");
}

Please correct me if I'm wrong.

Posted: Fri Apr 26, 2002 12:39 pm
by lc
Or you can do it using flat files as I do.

Meaning.. create a form, then when submitted check data... write into a textfile. Then if you want to display the data just get it from the textfile.

I got a number of scripts running on my site that do stuff like that. works fine.

Posted: Fri Apr 26, 2002 4:20 pm
by Jim
I was thinking of doing it using flat files, but I'll be honest...

I have no idea how.

Do you know of anywhere I might learn to write to other files this way?

Posted: Fri Apr 26, 2002 7:45 pm
by timmy
There are a few good scripts on the evilwarus.com codebase. Also, zend.con has a couple good tutorials on user management systems. Try buying a book on the subject, I'd recommend "PHP & MySQL Web Development" by Luke Welling and laura Thomson. There's alot of useful info there. Best thing to do is search for scripts other people have created, best way to learn is to see how somebody else does it, then you can adapt your own tweaks and such.

Posted: Fri Apr 26, 2002 8:06 pm
by lc
I agree.. get someone else's script that sorta resembles what you have in mind and take that apart.

I started learning at first by redoing someone else's guestbook script.