-2

Right now i am working on a Codeigniter project in which I am sending a link to the user to update their password, every thing is working according to the plan. Now all I need to know is that how can I extract data from URL that the user is following to update password.

Example: http://localhost/ciauth/user/password_reset/user@gmail.com/6f1bb1aeba261e92c390ac28d85267767038703e

I want to extract the code after the E-mail ID.

  • 2
    Possible duplicate of [Getting parts of a URL (Regex)](https://stackoverflow.com/questions/27745/getting-parts-of-a-url-regex) – Lomtrur Jun 17 '19 at 06:57
  • This question is fully compiled by me, I will appreciate if you take your down-vote back. –  Jun 17 '19 at 08:04

3 Answers3

2

Never mind i have solved it doing $url_code=$this->uri->segment(4);

This is okay. But it will be better if you implement it with your action function:

    public function password_reset($email, $code){
        // $email: user@gmail.com
        // $code: 6f1bb1aeba261e92c390ac28d85267767038703e
    }
InOrderToLive
  • 186
  • 1
  • 1
  • 9
  • 1
    don't forget `$email = null, $code = null` otherwise undefined if that segment isn't present. – Alex Jun 17 '19 at 07:34
  • thanks for your time, my code is working right now so i dont want to spend even 1 more second on it. –  Jun 17 '19 at 08:06
1

Try this, From this you can do extract full url, Place below code to your password_reset() to see your url extraction

echo'<pre>';print_r($this->uri->segment_array());die;
M.Hemant
  • 2,345
  • 1
  • 9
  • 14
0

Never mind i have solved it doing

$url_code=$this->uri->segment(4);