Asif Iqbal
Asif Iqbal

Reputation: 1236

HTML form is not working well with form input

This is my simple html from.

<form action="" method="post" enctype="multipart/form-data">
    Save your Contact form: <br>
    <textarea name="code" placeholder="Write your form html" rows="30" cols="100">
        <?php if(isset($_POST['code'])){ echo htmlentities($_POST['code']) ; } ?>
    </textarea>
    <br>
    Password<br>
    <input type="password" name="password"><br>
    <button type="submit">Create</button>
</form>

Output of it is: enter image description here

Now put sample input in the form code:

<form action="" method="post">
</form>

Now press "Create" button 2 times. First time it is ok. But in the second time I am getting unexpected output. How to solve this problem? enter image description here

1:

Upvotes: 2

Views: 71

Answers (3)

rocky
rocky

Reputation: 631

put header("X-XSS-Protection: 0"); after if(isset($_POST['code'])){ 
this issue is due to XSS Auditor refused to execute a script

Upvotes: 2

Pralhad Narsinh Sonar
Pralhad Narsinh Sonar

Reputation: 1454

  1. I assume after submission of the form data is being sent to .php script and then gets manipulated.
  2. Why are clicking on Submit buttom more than once? even though you are doing it - are you checking if same data is getting submitted ?
  3. Most important - you should have proper VALIDATION rules in place through JS or PHP to prevent any problems on form submission.

Upvotes: 0

Parth Patel
Parth Patel

Reputation: 824

Use Following code for button

<button type="submit">Create</button>

Upvotes: 0

Related Questions