mercredi 9 novembre 2016

How can I fix this error

I am learning php from w3school and I am trying to run this code but there is shown an error when I click submit button without filling the form. Here goes my code which is in a file named "form.php"

<html>
<body>
<style type="text/css">

</style>
<h2>PHP Form Validation Example</h2>
<form method="post" action="welcome.php">  
  Name: <input type="text" name="name">
  <br><br>
  E-mail: <input type="text" name="email">
  <br><br>
  Website: <input type="text" name="website">
  <br><br>
  Comment: <textarea name="comment" rows="5" cols="40"></textarea>
  <br><br>
  Gender:
  <input type="radio" name="gender" value="female">Female
  <input type="radio" name="gender" value="male">Male
  <br><br>
  <input type="submit" name="submit" value="Submit">  
</form>


</body>
</html>

Here is my another file named "welcome.php"

<?php

  $name = $_POST["name"];
  $email = $_POST["email"];
  $website = $_POST["website"];
  $comment = $_POST["comment"];
  $gender = $_POST["gender"];
    echo "<h2>Your Input:</h2>";
    echo $name;
    echo "<br>";
    echo $email;
    echo "<br>";
    echo $website;
    echo "<br>";
    echo $comment;
    echo "<br>";
    echo $gender;
    ?>

but when I submit form without filling the form its shown this.

Please someone help to find the error............




Aucun commentaire:

Enregistrer un commentaire