Jump to content

adding a .php page on sign up


almightyegg

Recommended Posts

As jesirose said, mod_rewrite is the simplest way. However, if you can't access mod_rewrite (like me, my webhost doesn't allow mod_rewrite for some stupid reason) setup a custom error page (let's call it 404.php) with this:

 

<?php
$req = $_SERVER['REQUEST_URI'];
$reqarr = explode('/', $req);
header("Location: http://www.mysite.com/userpage.php?id=".$reqarr[1]);
?>

 

That should do exactly what you need it to. So when somebody access http://www.mysite.com/username it'll transfer to http://www.mysite.com/userpage.php?id=username

well...I've gone back to writing a new page...I've got this:

$directory = mkdir("/home/koggdesi/public_html/$user[username]", 0777);
$file = fopen("$user[username]/index.php","w") or die("Cannot open file!");
$stringData = "header( 'Location: http://www.koggdesigns.co.uk/users/main.php?id=$userid' ) or die("Cannot DO!"));";
fwrite($file, $stringData);
fclose($file);

 

yet I get an error:

Parse error: syntax error, unexpected T_STRING in /home/koggdesi/public_html/activate.php on line 30

 

Line 30 is the $stringData = blah line

$stringData = "header( 'Location: http://www.koggdesigns.co.uk/users/main.php?id=$userid' ) or die("Cannot DO!"));";

 

It's your die statement, as the syntax highlight shows.

 

$stringData = "header( 'Location: http://www.koggdesigns.co.uk/users/main.php?id=$userid' ) or die('Cannot DO!'));";

 

That should do it.

Thanks I'd also added one extra bracket and left out the <? ?> to write in ;)

 

It now works!!!!!!!  :o BUT next problem is that if somebody has a space in their username their directory comes out funny when you type it in :P any ideas how to add a - or _ or some symbol inbetween each word?

Hmm...don't allow them to register with spaces in their username? ;D

 

Other then that, you might want to do a preg_replace(" ","_",$user[username]) to add them in. Then preg_replace("_"," ",$whatever) to remove them again.

 

Though this in itself would eliminate the ability for a user to have the same name with an underscore where the space is, and vice versa. This is assuming all usernames with a "_" are the same as all usernames with a " ". However, if you used some oddball character, you should be good.

 

There's also urlencode() and urlencode(). Look them up, as they'll allow you to not have to use replacements.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.