Welcome Guest, Not a member yet? Register   Sign In
getting segment problem.
#1

[eluser]cehennem[/eluser]
hello.

I am new to CI. Now I am trying to make a user registration system that has a reference member feature.

I have a controller named "register.php" and I am loading the registration form at index()

Now I need to get the second segment as a reference id. Forexample if your user id is 1234, your registration form with reference code should be:

www.site.com/register/1234

and if there is no reference number, the route system should load the same function without any reference

Should I use routes for this functionality?
#2

[eluser]cehennem[/eluser]
or a similar question to above;

I need to route ..com/register/ to controller register.php's index() function. but there is an optional parameter like ..com/register/343242 and I should be getting this integer as a variable.
#3

[eluser]InsiteFX[/eluser]
CodeIgniter Users Guide - URI Class
#4

[eluser]boltsabre[/eluser]
Just as a thought, why would you want to display the users ID in your URL....??? it's a bit of a security risk. Remember that using the URL is the same (in terms of security) as using $_GET, very open to user abuse, a monkey can simply change your URL and bang... you're registering a user with a different ID...

I'd use a hidden input instead.

But even then, you still need to do some data cleansing / validation -> there are plugins that allow users change post values. So an educated monkey can still change hidden inputs.
#5

[eluser]Aken[/eluser]
And a hidden input is going to be any less abusable? C'mon...

There's nothing wrong with using IDs or something in the URL. Just make sure you validate everything properly.

And yes, you would use a route or if your register URL is a function (not a controller index), then you can use the ID as a parameter. http://ellislab.com/codeigniter/user-gui.../urls.html




Theme © iAndrew 2016 - Forum software by © MyBB