Jump to content

Recommended Posts

Hello.

Following from my earlier post; I want to be able to allow users to sign up to my community site, and create a folder from their username.  So their page on the site will be www.site.com/user.

 

Making the folder part is fine using mk dir.

 

However, i have no idea of how to create an index.php file that has my profile template on it or how to pump out the correct users data.

I imagine though that the file is created with a variable in it such as $user  = x so that it pumps out the correct user data.

 

Any help would be great.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/51893-solved-creating-a-new-page/
Share on other sites

But, I would use mod_rewrite and a template instead of creating each user a page of his own. This way it will appear like the user has his folder, but everything would go through one file.

 

Orio.

 

Ah right. I see. Is this easy to do for some one who has a novice knowledge of php?

Or near enough anyway.

 

However, would this allow people to goto www.site.com/user and see the users profile?

 

Thanks Orio

<?php
$username = $_GET["username"];
$q = mysql_query("SELECT * FROM users WHERE username = '$username'");
...
?>

That's not good! (SQL Injection)

Better to allow only Letters, Numbers, Underscores (_), Lines (-) and spaces:

<?php

$username = $_GET["username"];
if (!preg_match('/^[\w\d\s\-_]+$/', $username)) die('wrong username');

$q = mysql_query("SELECT * FROM users WHERE username = '$username'");
$are = mysql_fetch_assoc($q);

echo "Welcome to ".$username."'s profile page.";

?>

And also ... SELECT * ... is very slow. Use

SELECT `user_data1`, `user_data2`, ... FROM ...

That's more quick

Can i just check that these are correct?

 

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/\.]+) 

profile.php?user=$1 [nc]

 

<?php
include ("global.php");

$username = $_GET["username"];
if (!preg_match('/^[\w\d\s\-_]+$/', $username)) die('wrong username');

$q = mysql_query("SELECT * FROM users WHERE username = '$username'");
$are = mysql_fetch_assoc($q);

echo "Welcome to ".$username."'s profile page.";

?>

 

Thanks

Nick

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.