Page 1 of 1
MySQL
Posted: Sun Aug 01, 2004 10:36 pm
by dwfait
Hi. I was wondering, how would i create one MySQL database, with one table, with three headers? user ID, username and password, through Cpanel?
and then if you could tell me how to add new values to these headers / get the current user id? like, check how many ID's there are, if there are none create one like:
userid:"1"
name:"name"
password:"password"
but if there allready is one make the new userid "2"
Thanks, if you could answer either one of these questoins you would be a great help.
Posted: Sun Aug 01, 2004 10:54 pm
by qads
you should really get
phpmyadmin
Posted: Sun Aug 01, 2004 11:03 pm
by Fanstop.tk
best way: Use PHP code.
Code: Select all
<?php
$sql = "create table Guests (id int not null auto_increment primary key, Username varchar(25), Password varchar(25))";
mysql_query($sql) or die("Unable to create table");
?>
To add info, do this:
Code: Select all
<?php
$sql = "insert into Guests (Username, Password) values ('Insert Username here','Insert Password here')";
mysql_query($sql) or die("Unable to add information");
?>
Hope this helps.
One more thing, I would use METHOD="POST" on any forms submitting this info, then use the $_POST variable to attain the info... also, encrypt any incriminating data (password) so if the db is hacked, the data is safe.
Posted: Sun Aug 01, 2004 11:10 pm
by dwfait
Wouldnt you need to connect to the MySQL server and database first?
I would need the code for that, as i am a complete noob at PHP :-\. and also, why Guest?
Re: MySQL
Posted: Sun Aug 01, 2004 11:13 pm
by burzvingion
dwfait wrote:Hi. I was wondering, how would i create one MySQL database, with one table, with three headers? user ID, username and password, through Cpanel?
cPanel doesn't have any support for doing anything with databases, but phpmyadmin is very nice and free.
but if you want to do it all in php, search for mysql at php.net...
Posted: Sun Aug 01, 2004 11:42 pm
by dwfait
I would need the full PHP code needed to open up an MySQL database, open up a table in there, and search for a value in the field 'user' which is the same as the _POST method text entry via form 'user'.
Posted: Sun Aug 01, 2004 11:55 pm
by d3ad1ysp0rk
Why not learn it yourself?
Or would you like us to move this to Volunteer work/Job hunt (if you're willing to pay)
This community is about helping people learn, not coding it for them
Sorry if I sound harsh, it's 1am and ive gotten 6 hours of sleep in the last 42 hours.
Posted: Mon Aug 02, 2004 12:11 am
by dwfait
heh, i am trying to learn from PHP builder's php manual, but its a bit confusing, however i have made progress. I have connected to my database, selected my table, i just want to search the table now to see if the user has entered right user/pass.
im really stuck on this, so if someone could tell me how to:
search for the entered username in the table (entered by form)
then see if entered password matches the password in the row of the matching username, assuming $user is entered username, and $pass is entered pass. This would be a great help.
Posted: Mon Aug 02, 2004 12:36 am
by dwfait
Nevermind, i have figured it out

. I am using:
<?php
$link = mysql_connect("localhost", "root", "")
or die("Could not connect");
mysql_select_db("stormst_sspp")
or exit("Could not select database");
$result = mysql_query("SELECT user AND pass FROM sspp WHERE user='one' AND pass='one'")
or die ("Invalid query");
$num_rows = mysql_num_rows($result);
echo "$num_rows";
mysql_close($link);
?>
Posted: Mon Aug 02, 2004 9:40 am
by Draco_03
Cpanel HAS phpmyadmin in it...