Hi all
I’ve been looking around and cant find anything that explains how to change the url address from Id to a username instead
E.g profile.php?id1 instead profile.php/username
Any help would be brillant
Thanks Ian
Hi all
I’ve been looking around and cant find anything that explains how to change the url address from Id to a username instead
E.g profile.php?id1 instead profile.php/username
Any help would be brillant
Thanks Ian
If you don’t mind using ?username, then:
some-link.php?username=TestUser
Would become:
[php]$username = $_GET[‘username’];[/php]
If, on the other hand, you want to have the /username, then you’d need to check the request URL:
[php]$raw = $_SERVER[‘REQUEST_URI’];
$parts = explode(’/’, $raw);
$username = $parts[1];[/php]
Hi thanks for the reply , where would this code go ?
The process I have so far is
Register
Email activation
Then a register details page this is where I asign the url to the user so at the moment its site.com/profile.php?id1.
I know how to change this to the username so site.com/username but don’t no where I would apply the code you have given so soneone could type that directly to the url
Thanks again
Ian
Can you post the code for the register details page?
[php]<?php include(“users/connection.php”);
ob_start(); // start outpub buffering
// set variable blank to apend to
$error ="";
$active = “”;
// get the details from the url & filter
preg_replace(’%[^A-ZA-Z[0-9]%i’,’’,$_GET[‘id’]);
preg_replace(’%[^A-ZA-Z[0-9]%i’,’’,$_GET[‘code’]);
$id = $_GET[‘id’];
$code= $_GET[‘code’];
//error messages if the id and code chars are invailed
if(!$id) {
$error .=“Invailed Activation id”;
}
if(!$code) {
$error .=“Invailed Activation Code”;
}
// query to check if the id and code are valid
$sql = mysql_query(“SELECT * FROM acts WHERE id = ‘$id’ AND code =’$code’”);
//get the number of rows
$num_rows = mysql_num_rows($sql);
if($num_rows == 1) {
$update = mysql_query("UPDATE acts
SET activated = ‘1’ WHERE id =’$id’ ");// make the account active
$active .= “
?>
Account Activated <?php if(!empty($error)) { echo $error ;} // display error messgaes?> <?php if(!empty($active)) { echo $active ;}// display account now active message?> <?php // if the account has been actived show this form else show error message if($created == 1 ) { echo 'Create your rider | |
*Act name | |
*Act Genre | |
*Location | |
*Food | No Yes |
*Drinks | No Yes |
*Accommodation | No Yes |
*Travel Costs | No Yes |
*Extra Fees | No Yes |
*Booking contact Number | |
*Secert question (1) | Whats the name of your first school Whos your idol Whats your mothers maiden name |
*Answer | |
*Secert question (2) | Whats the name of your first pet Whats the name of your local hospital What make was your first car |
*Answer | |
*Territory(1) | |
*Booking email address | |
Territory(2) | |
Booking email address | |
Bio (optional) | |
Social Media | |
Facbook URL | |
Sound Cloud URL | |
Help your act get found ! | |
Search keywords | |
(e.g location , music type ) | |
Your profile url | |
I am validating the input and inputting the data to the database on another page as i couldnt get the update to work on the same page , i have now found out why so i can change it back if thats needed ,
Thanks
Ian
Also i have just spotted an error in the preg_replace thats been changed now.