A
A
Alex Ponomarev2020-09-01 13:43:38
PHP
Alex Ponomarev, 2020-09-01 13:43:38

Can't delete data from SQL DB. where is the mistake?

<div class="adm1">Удаление учащегося по телефону</div>
  <form action="" method="post">
      <input class="adm2" type="text" name="tel1" placeholder="Телефон">
      <input class="adm2" id='btn' type="submit" value="Удалить">
  </form>
  
  <?php

  if (isset($_POST['tel1']))
  {
  $tel = $_POST["tel1"];
  $mysqli = new mysqli($db_host,$db_user,$db_password,$db_base);
  $result = mysqli_query($mysqli, "DELETE FROM mytable2 WHERE tel = $tel");
  echo "<script>window.location.href='index10.php'</script>";
  }


the goal is to delete all user data by phone number. For example, the format "+79220022340" deletes all user data with this number

"+792200f22340" and such a phone number with an error "f" cannot be deleted, I enter the number, click change, but the deletion does not occur.

I don’t even know how to formulate the question in order to find a solution online. I'm just learning so don't be strict there is a simple question

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
necrodeflorator, 2020-09-01
@rusindex

after $result = mysqli_query($mysqli, "DELETE FROM mytable2 WHERE tel = $tel");
write if (!$result) die(mysqli_error($mysqli));
MySQL will tell you what's wrong

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question