Dhrubo Naskar
Dhrubo Naskar

Reputation: 43

Url form submission codeigniter

I am new to codeigniter, I am trying to use url as the form submission in codeigniter. The home page is having a form submission with fields like city, date and submit. The url it redirects to is domain.com/HotelSearch/amsterdam/1 but if I use the link directly for example domain.com/HotelSearch/Paris/1 it will not open anything. How can I use the url to submit Paris as the city and redirect to the result page. In an another method when I use hidden input values in the form it also works like that.

    <form method="post" action="<?php echo VPATH; ?>searchHotel/Singapore/1" style="margin: 0;">
        <a href="javascript:void(0);" onclick="$(this).closest('form').submit()"  >
            <img src="<?php echo IMAGE; ?>hotl02.jpg" class="img-responsive" alt="Responsive image">
        </a>
        <input type="hidden" name="city" value="Singapore" />
        <input type="hidden" name="checkindate" value="<?php echo $today; ?>" />
        <input type="hidden" name="checkoutdate" value="<?php echo $posttoday; ?>" />
    </form>

Upvotes: 0

Views: 77

Answers (1)

Yinka Martins
Yinka Martins

Reputation: 1

You'll have to edit the controller code. The url is in segments. You can grab each segment using $this->uri->segment(n) where n is the segment. for example: http://www.hotelsample.com/searchHotel/Singapore/1

$this->uri->segment(1) will give searchHotel $this->uri->segment(2) will give Singapore. With this you can swipe out the city and process. Goodluck

Upvotes: 0

Related Questions