Skip to content
Advertisement

Enter button gets trigrred while enter new line in input form

im working on a project where a user can describe his location in multiple lines but when i press enter button for new line in input form it gets submitted into database. i feel myself stucked here. help me to get rid of this please

my html code is:

<form method="POST" id="name-form">
  <div class="h4">Describe Location</div>
  <input type="text" value='Describe Location' name="disc" class="input-formm">
  <input type="submit" value="discribe" name="discribe" class="edit-button">
</form>

and my php code is :

if (isset($_POST['discribe'])) {
    $disc =  htmlspecialchars(trim($_POST['disc']));
    $qry =  "UPDATE `Location` SET disc=:disc WHERE city = :city";
    $result = $conn->prepare($qry);
    $result->bindParam(':disc', $disc, PDO::PARAM_STR);
    $result->bindParam(':city', $city, PDO::PARAM_STR);
    $result->execute();
}

please help me

Advertisement

Answer

Instead of using “<input type=”text” …>” you can use “<textarea ..>” markup. It can be easily used in forms and shouldn’t submit on enter while in this text area.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement