Same download form for different pages, how to save to which page was downloaded?

Asked

Viewed 25 times

0

A client’s website has the same form for all pages (where there is the possibility of downloading a file, the person must fill in before making a download). Only the customer wants to know which page the customer was on when they downloaded it. My question is what could I do to save in the database beyond the form data, the url where the person was, something like.

Follow code of the registration function below:

form_text; ? > cover) & & $report->cover): ? > cover->file_name); ? >" alt="Title cover) ? $report->title : "Report"; ?>">

    <div class="register-section__column">
        <?php echo form_open(site_url("subscriptions/register"), array("class"=> "register-section__form")); ?>
            <div class="register-section__input-container">
                <label for="name" class="register-section__label"> <?php echo lang('form-name'); ?> </label>
                <input name="name" type="text" class="input" placeholder=" <?php echo lang('place-name'); ?> " required>
            </div>
            <div class="register-section__input-container">
                <label for="email" class="register-section__label"> <?php echo lang('form-email'); ?> </label>
                <input name="email" type="text" class="input" placeholder=" <?php echo lang('place-email'); ?> " required>
            </div>
            <div class="register-section__input-container">
                <label for="phone" class="register-section__label"> <?php echo lang('form-phone'); ?> </label>
                <input name="phone" type="text" class="input" placeholder=" <?php echo lang('place-phone'); ?> " required data-mask-type="phone">
            </div>
            <div class="register-section__input-container">
                <label for="organization" class="register-section__label"> <?php echo lang('form-company'); ?> </label>
                <input name="organization" type="text" class="input" placeholder=" <?php echo lang('place-company'); ?> " required>
            </div>
            <div class="register-section__input-container">
                <label for="purpose" class="register-section__label"> <?php echo lang('form-destiny'); ?> </label>
                <div class="select-mask">
                    <select name="purpose" class="select" required>
                        <option value=""> <?php echo lang('form-destiny-bf'); ?> </option>
                        <option value="negocios"> <?php echo lang('form-destiny-business'); ?> </option>
                        <option value="pessoal"> <?php echo lang('form-destino-personal'); ?> </option>
                    </select>
                </div>
            </div>
            <div class="register-section__input-container">
                <label for="associated" class="register-section__label"> <?php echo lang('form-associated'); ?> </label>
                <div class="register-section__input-radio-group">
                    <div class="container-radio">
                        <input id="associated_yes" type="radio" name="associated" value="1" required>
                        <label for="associated_yes"> <?php echo lang('form-associated-yes'); ?> </label>
                    </div>
                    <div class="container-radio">
                        <input id="associated_no" type="radio" name="associated" value="0" required> 
                        <label for="associated_no"> <?php echo lang('form-associated-no'); ?> </label>
                    </div>
                </div>
            </div>
            <div class="register-section__input-container">
                <button type="hidden" class="submit"> <?php echo lang('form-register'); ?> </button>
            </div>

        </form>
    </div>
</div>

2 answers

0

0

You can put a input of the kind hidden in your form that holds the value of URL current page, see:

<input type="hidden" name="origin" value="<?= $_SERVER['REQUEST_URI']; ?>" />

This way whenever the form is sent it will also include the name of the page from which it was submitted.

$data = $this->input->post();
// $data tera um valor "origin" com a url da pagina da qual o formulario foi enviado

Another option is to take the "previous url" to which the form is being processed:

$previousURL = $_SERVER['HTTP_REFERER'];
  • Nice tie, is it? <button type="Hidden" value="<?= $_SERVER['REQUEST_URI']; ? >" class="report-type_header_button js-scroll-to-download">Download</button> And how would I save the url to the database?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.