Creating ID's

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

sk8erh4x0r
Forum Commoner
Posts: 43
Joined: Wed May 26, 2004 8:27 pm

Creating ID's

Post by sk8erh4x0r »

Having trouble creating ID's for users on my webpage... need help
?>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

What sort of ID's? Sessions?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Hmm sk8er you need to be more specific. (Its ur bud from mediamonks here by the way, hehe). Anyway if it's still the problem with your viewprofile use something along the lines of:

<?php
$show = $_GET['ID'];
$link = mysql_connect($host, $user, $pass);
mysql_select_db($dbname) or die("couldnt connect" . mysql_error());
$sql = "SELECT * FROM $tblname WHERE ID = '$show'";
$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result))
{
$row = mysql_fetch_array($result);

etc, etc...
?>

It has nothing to do with ID's. I just used ID as a variable example, lol.

Peace man 8)
Last edited by Joe on Wed May 26, 2004 8:34 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

creating what kind of ID's? user id, session id, unique id, global/universal unique id (GUID or UUID)..
sk8erh4x0r
Forum Commoner
Posts: 43
Joined: Wed May 26, 2004 8:27 pm

little more detailed...

Post by sk8erh4x0r »

The ID's i am setting up are user ID's. People are able to register accounts there. When an account is created, it sends the info to the mySQL database and opens up a userinfo page. On that userinfo page, I want the ID to show up in the URL. Ex.

URL_HERE/userinfo.php?ID=sk8erhacker


How do i set up that ?ID= ?
Last edited by sk8erh4x0r on Wed May 26, 2004 10:14 pm, edited 1 time in total.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

I just told you the code required to make a userinfo profile. If your asking how the ID can forward you to the userinfo page when you click it's link you should setup a variable and a new db column. The variable should go like:

$user = "<A href=http://www.securityglitch.com/userinfo. ... rname."</A>";
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you could use auto_increment attribute here.

it would look like

user.php?id=8

or just use mysql_fetch_array to get the row['username'] and just connect to the sql server via the $_POST OR $_GET method to get the exact record(s) of the specific username
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

http://www.securityglitch.com/Tutorials/

The fact that you have "Hacking" and "Cracking" in the same tutorials list makes me not want to help you much. :\

edit: also, check the freewebs TOS. I don't believe they allow illegal things to be hosted on their sites.
Also, try a new template.
sk8erh4x0r
Forum Commoner
Posts: 43
Joined: Wed May 26, 2004 8:27 pm

Post by sk8erh4x0r »

lol. I'm not getting hosting off of FreeWebs... plus, if u click on hacking or cracking, its a dead end. I haven't gotten to that part of the site yet. They're just there as fillers. :)
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Hey LiLpunkSkateR, I must say that your opinion against security enthusiasts is very low. Do you know anything about hacking and what it's purpose is. I do not think the person in question is planning to destroy anything. Instead I think he's just trying to improve his security skills to prevent any unwanted intrusions to his property. And as for the freewebs problem, well I had a look and noticed that nothing from the freewebs server which is being used on that site is illegal at all.

Do not judge ones thoughts, we are all individuals!


Regards 8)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

tim wrote:you could use auto_increment attribute here.

it would look like

user.php?id=8

or just use mysql_fetch_array to get the row['username'] and just connect to the sql server via the $_POST OR $_GET method to get the exact record(s) of the specific username
Actually, I would personally use this approach, as it's very, very hard to have a primary unique id/key to apear twice. It's the most common version imho ( as seen on this very board, the u=11209 part of profile.php?mode=viewprofile&u=11209 )

If you use an auto_increment id, you have more than half the work done made.
sk8erh4x0r
Forum Commoner
Posts: 43
Joined: Wed May 26, 2004 8:27 pm

Ok

Post by sk8erh4x0r »

I'm having trouble with this auto_increment thing. I have a column set as:

field = id, type = varchar, length/values* = (none), attributes = (none), null = not null, Default** = (none), Extra = auto_increment.

When i go to save i get the error saying that it is incorrect. Any help?[/mysql_man]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

type should be int, I think for auto-increment to work..
sk8erh4x0r
Forum Commoner
Posts: 43
Joined: Wed May 26, 2004 8:27 pm

Post by sk8erh4x0r »

Ok. That did work, but now do i set that up in the PHP code so it sets an ID # when someone signs up?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

just use INSERT, for each new incoming row into the table, it will attach a id number to it.

some people do something like this

INSERT INTO table_name VALUES (' ', '$var', '$var2');

where the '' means the id field.
Post Reply