Home > Software design >  Prevent front end users from sending requests from changed webpage
Prevent front end users from sending requests from changed webpage

Time:02-08

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.

CodePudding user response:

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>
  •  Tags:  
  • Related