Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 561573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:27:49+00:00 2026-05-13T12:27:49+00:00

On my PHP site, currently users login with an email address and a password.

  • 0

On my PHP site, currently users login with an email address and a password. I would like to add a username as well, this username they g\set will be unique and they cannot change it. I am wondering how I can make this name have no spaces in it and work in a URL so I can use there username to link to there profiles and other stuff. If there is a space in there username then it should add an underscore jason_davis. I am not sure the best way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:27:50+00:00Added an answer on May 13, 2026 at 12:27 pm
    function Slug($string)
    {
        // convert to entities
        $string = htmlentities( $string, ENT_QUOTES, 'UTF-8' );
        // regex to convert accented chars into their closest a-z ASCII equivelent
        $string = preg_replace( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string );
        // convert back from entities
        $string = html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
        // any straggling caracters that are not strict alphanumeric are replaced with a dash
        $string = preg_replace( '~[^0-9a-z]+~i', '-', $string );
        // trim / cleanup / all lowercase
        $string = trim( $string, '-' );
        $string = strtolower( $string );
        return $string;
    }
    
    $user = 'Alix Axel';
    echo Slug($user); // alix-axel
    
    $user = 'Álix Ãxel';
    echo Slug($user); // alix-axel
    
    $user = 'Álix----_Ãxel!?!?';
    echo Slug($user); // alix-axel
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently getting data from a users profile when they login through facebook,
I have a website where users can enter their Twitter Login information. This site
I've got a PHP-based site where we allow users to upload a comma-separated text
I'm currently trying to expand my PHP driven intranet site for my company. It
<fb:login-button onlogin=window.location = '/custompage.html';>Connect</fb:login-button> That's currently my code for users to log in to
I currently have a Joomla 1.5 installation, as well as another website. They both
I'm building a PHP site, but for now the only PHP I'm using is
I'm doing a PHP site which displays code examples in various languages (C#, PHP,
I'm trying to get a PHP site working in IIS on Windows Server with
I'm in the process of making my PHP site Unicode-aware. I'm wondering if anyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.