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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.