MySQL
Moderator: General Moderators
MySQL
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.
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.
you should really get phpmyadmin
-
Fanstop.tk
- Forum Newbie
- Posts: 17
- Joined: Wed Jul 21, 2004 11:02 pm
best way: Use PHP code.
To add info, do this:
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.
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");
?>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");
?>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.
-
burzvingion
- Forum Newbie
- Posts: 11
- Joined: Sun Apr 18, 2004 2:30 pm
Re: MySQL
cPanel doesn't have any support for doing anything with databases, but phpmyadmin is very nice and free.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?
but if you want to do it all in php, search for mysql at php.net...
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
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.
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.
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);
?>
<?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);
?>