TDJ
TDJ

Reputation: 59

Prevent front end users from sending requests from changed webpage

Suppose I have disable a button on the front end and any user can enable it by Chrome tools. How can I prevent it? Can I validate whether the request front end is changed?

I use Codegniter.

Upvotes: 1

Views: 55

Answers (1)

Wakeel
Wakeel

Reputation: 5010

You can track by having a state in your controller passed down to the view.

function contact()
{
  $disabled= true;

  if($this->input->post('submit') && ! $disabled)
  {
    //do something

  }
  
  $this->load->view('contact', ['disabled' => $disabled]);
}

In your view will be

  <button name="submit" <?= $disabled? 'disabled="disabled"': '' ?>>Submit</button>

Upvotes: 1

Related Questions