CodeIgniter Forums
Question mark problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Question mark problem (/showthread.php?tid=70265)



Question mark problem - theedo - 03-15-2018

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!


RE: Question mark problem - Zeff - 03-15-2018

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 '?'


RE: Question mark problem - InsiteFX - 03-15-2018

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.


RE: Question mark problem - theedo - 03-15-2018

(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!


RE: Question mark problem - JayAdra - 03-19-2018

Why allow a question mark in a username in the first place?


RE: Question mark problem - InsiteFX - 03-20-2018

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.