Bird
0
0

Identify the error in this Laravel Blade form snippet:

medium📝 Debug Q14 of 15
Laravel - Request and Response
Identify the error in this Laravel Blade form snippet:
<form method="POST" action="/save">
  <input type="text" name="email">
</form>
AInput name attribute is not allowed
BInput type should be 'email' not 'text'
CForm action URL is invalid
DMissing @csrf directive for security
Step-by-Step Solution
Solution:
  1. Step 1: Check for CSRF protection in POST forms

    Laravel requires a CSRF token in POST forms to prevent attacks. This form lacks @csrf.
  2. Step 2: Validate other parts

    Input type 'text' is allowed for emails (though 'email' is better), action URL is valid, and name attribute is required.
  3. Final Answer:

    Missing @csrf directive for security -> Option D
  4. Quick Check:

    POST forms need @csrf [OK]
Quick Trick: Always add @csrf in POST forms [OK]
Common Mistakes:
  • Forgetting @csrf causes 419 error
  • Thinking input type must be 'email' for emails
  • Assuming action URL must be absolute

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes