Welcome Guest, Not a member yet? Register   Sign In
How to redirect using $this-session-userdata(country_territory)
#11

You can store the users id in the session then assign it to the view data.

PHP Code:
$data['userID'] = $userID

Then in your view you can create the link like so or use CodeIgniters anchor helper.

PHP Code:
<a href="<?= base_url('adverts/createadvert/'.$userID);?>">Create Advert</a
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 09-28-2019, 08:05 AM by christaliise.)

(09-28-2019, 03:42 AM)InsiteFX Wrote: You can store the users id in the session then assign it to the view data.

PHP Code:
$data['userID'] = $userID

Then in your view you can create the link like so or use CodeIgniters anchor helper.

PHP Code:
<a href="<?= base_url('adverts/createadvert/'.$userID);?>">Create Advert</a

Thanks InsiteFX. I've created the variable in the Adverts Controller-

PHP Code:
$user_id $this->session->userdata('user_id'); 

And this link in the view-

PHP Code:
<a href="<?php base_url('createadvert/'.$user_id);?>">CreateAdvert</a

My system rejected the above, first by the 2nd "=" so I deleted that, but it is still giving an error.

I realize I need to do a lot more work. Once the advert is created I want it saved by the user_name presumably in the root directory.

However, I first want to get the Layout to work.
Reply
#13

(This post was last modified: 09-28-2019, 08:17 AM by InsiteFX.)

Change this:
PHP Code:
<a href="<?php base_url('adverts/createadvert/'.$user_id);?>">CreateAdvert</a

To this:
PHP Code:
<a href="<?php echo base_url('adverts/createadvert/'.$user_id);?>">CreateAdvert</a

Your missing the echo statement.

Also links are Controller/Method
What did you Try? What did you Get? What did you Expect?

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

(09-28-2019, 08:11 AM)InsiteFX Wrote: Change this:
PHP Code:
<a href="<?php base_url('adverts/createadvert/'.$user_id);?>">CreateAdvert</a

To this:
PHP Code:
<a href="<?php echo base_url('adverts/createadvert/'.$user_id);?>">CreateAdvert</a

Your missing the echo statement.

Also links are Controller/Method

It is still giving an error - undefined variable user_id. It is defined in the Controller and I also defined it in the view but still nothing works.
Reply
#15

Move this line from controller to view:
PHP Code:
$user_id $this->session->userdata('user_id'); 

Or put the $user_id in an array which is passed to the view.
Controller:
PHP Code:
$data['user_id'] =  $this->session->userdata('user_id'); 
$this->load->view('createadvert'$data); 

In both cases, the $user_id variable will be available in the view.
Reply
#16

(09-28-2019, 10:16 AM)Wouter60 Wrote: Move this line from controller to view:
PHP Code:
$user_id $this->session->userdata('user_id'); 

Or put the $user_id in an array which is passed to the view.
Controller:
PHP Code:
$data['user_id'] =  $this->session->userdata('user_id'); 
$this->load->view('createadvert'$data); 

In both cases, the $user_id variable will be available in the view.

Thanks Wouter60, I did try your first option but it didn't work, or at least open the page. I do need to put more coding into the Controller to try your 2nd option.

Can you answer my previous query about before a User creates an advert I want to give them an option of the advert layout, for example the "Description - Images - Ingredients - Details" to be in different places on the page?

Similar to what Yahoo do in the layout of email pages. Do you know of any site where I can learn that?
Reply
#17

Quote:Thanks Wouter60, I did try your first option but it didn't work (…).

I'm sorry, christaliise, but I'm clearly not the right person to help you.
Reply
#18

(09-29-2019, 03:59 AM)Wouter60 Wrote:
Quote:Thanks Wouter60, I did try your first option but it didn't work (…).

I'm sorry, christaliise, but I'm clearly not the right person to help you.

I found this site for page layout. https://www.w3schools.com/html/html_layout.asp
Reply
#19

Why not just use Bootstrap 4 Grid?
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