Welcome Guest, Not a member yet? Register   Sign In
Question mark problem
#1

(This post was last modified: 03-15-2018, 08:45 AM by theedo.)

Hi to everyone! I'm making a CMS based on Codeigniter for a project. But I've a (maybe, I don't know) "big" problem.

I've a database with some users registered. Some of these has the ? in their name and when I go to their profile page I see "404 Not Found".

Now, I load profile in this way: (the controller)
PHP Code:
public function view($username){ 

and I did a route:
PHP Code:
$route['profile/(:any)'] = "profile/view/$1"
Instead: if the username is ?ABC, I'll have 404 on exxample.com/profile/?ABC.
I think that I allowed the ? in the permitted_uri:
PHP Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?'

Do you have some idea to solve my problem? thank you!
Reply
#2

Hi Theedo,

A question mark is reserved for use in query strings:
Typical URL containing a query string is as follows:
http://example.com/search?name=ferret
CI always uses: http://example.com/index.php?/bla/bla behind the scenes of mod_rewrite.
Don't have the time to figure it out for now, but I think you should find a way to encode the '?'
Reply
#3

The way we did our user profiles was to use their user_id for the profile directory name.
If you use a MySQL auto increment field for the user_id it will be unique.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(03-15-2018, 09:32 AM)InsiteFX Wrote: The way we did our user profiles was to use their user_id for the profile directory name.
If you use a MySQL auto increment field for the user_id it will be unique.

Hey, hello! Thank you for the ideaaaa! I wasn't thinking about the user_id! I could use it (and I'll do).

However, there is no solution for the username?
Thank you!
Reply
#5

Why allow a question mark in a username in the first place?
Reply
#6

if you have either the user name or the user id then you can look it up in the database.

The only thing we stored for the user in the profile folder was resources, everything else
was stored in a database profile table using the users ID.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB