Click to See Complete Forum and Search --> : profile system question


Heavy Metal
07-07-2006, 09:24 PM
I am developing a profile system, and I want to have a interface where they can go to http://www.mysite.com/profile.php?id=1 and it will show the first user in the databases profile. Now, I know how I would do this, but I want to know how to add a new thing when someone registers. Like say when member number two registers, it automatically adds id=2 to the code. Any ideas on how to do this?

delr2691
07-07-2006, 10:26 PM
I didnt get you...
You mean when someone registers a new account, you want it to redirect to his/her profile? or what?
Explain please :)

If you want to redirect the user after he registers a new account, you can retreive the id by using mysql_insert_id() function right after you do the insert query.. That will return the id and you can replace the location as usual..

NogDog
07-07-2006, 10:27 PM
Not sure if this is what you mean, but you could query the DB for the last ID number, then use that in the link:

SELECT userid FROM usertable ORDER BY userid DESC LIMIT 1;

Heavy Metal
07-07-2006, 10:34 PM
No, I do not want to redirect when they register. I want to set up a link, when someone registers, I want it to automatically make a link to there profile, which would be profile.php?id=(id number here). For Example, http://www.devhardware.com/forums/member.php?u=32481 is the url to my profile(sorry for link) on that place. I am wanting to be able to do that, thus I would have something in the register script add something to a file I suppose that would generate a pre-defined profile layout. If you do not understand it from here, I dont really know how to explain it to you.

delr2691
07-07-2006, 10:47 PM
ok.. i think i got you now..
now, assuming you have the username stored in a session or whatever you use to authenticate your user..
you can do this:

$uname="bla"; //where you store the username information (ie: $_SESSION['uname'])
$sql="SELECT userid FROM usertable WHERE username='".$uname."' LIMIT 1"
$doSql=mysql_query($sql, $conn); //Where $conn is your db connection
$row=mysql_fetch_assoc($doSql);
$ID=$row['userid'];
echo '<a href="profile.php?userid='.$ID.'">Go to your profile!</a>';

Hope it was what you wanted..

Heavy Metal
07-07-2006, 11:00 PM
Hmmmm, That was weird, I was just writing out to you what else I wanted to do with that, and I figured it out exactly. That is twice today I have figured out how to do something on my own after thinking about it for a bit. I think I may just be getting better at this. :D. Anyways, (That really is weird how that works out)Thanks for all your help mate. Cya.

delr2691
07-07-2006, 11:06 PM
ohh, ok.. that's good.. :) Keep improving, then.. :D

Heavy Metal
07-07-2006, 11:08 PM
You know, this thing started out as a User System, And now it is turning into something more along the lines of a Content Management System, I am adding all kinds of modules to it for managing a site. I cant wait for another year or two until I am done (:P Joking about the time peroid). Anyways, Again, Thanks for your help.

delr2691
07-07-2006, 11:15 PM
that's good, that's good.. :) i bet it will be a matter of few months.. ;)
hey and I checked your site, and I was just about to send a comment throught the Contact Us form but there's an error in the script.. Anyway, if you need some help with php, don't doubt to ask.. :D

Heavy Metal
07-07-2006, 11:22 PM
Ahh, Yes, that error, I dont know why that happens to me, I made a small mistake in there. Anyways its fixed now so feel free to send away. Also, Feel free to sign my guestbook :D