Answer the question
In order to leave comments, you need to log in
Pass variable using POST method...?
There is a form:
<form action="php/post_delete.php" method="post">
<input type = "text" name="' .$result['id']. '" hidden />
<input type="submit" value="Удалить"><br>
</form>';
<?php
//тут подключение к БД
?>
<?php
$id = $_POST[$result['id']];
$query = database::query("DELETE FROM 'punk' WHERE id =" $id "");
?>
$id = $_POST['id'];
$id = $_POST[name];
$id = $result['id'];
Answer the question
In order to leave comments, you need to log in
Show the contents of mail.php because it should be sent through it. Ajax simply dynamically returns an "Ok" or "An error occurred!" result, and before that, jQuery.validation checks that the form fields are filled in correctly.
Understand your PHP script, read - php.net/manual/ru/function.mail.php Understand
the location of the mail.php file, your paths are different in your examples
Yes, with ways it is visible and the truth a trouble.
Here is the mailer code:
<?php
$method = $_SERVER['REQUEST_METHOD'];
//Script Foreach
$c = true;
if ( $method === 'POST' ) {
$project_name = trim($_POST["project_name"]);
$admin_email = trim($_POST["admin_email"]);
$form_subject = trim($_POST["form_subject"]);
foreach ( $_POST as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
} else if ( $method === 'GET' ) {
$project_name = trim($_GET["project_name"]);
$admin_email = trim($_GET["admin_email"]);
$form_subject = trim($_GET["form_subject"]);
foreach ( $_GET as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
}
$message = "<table style='width: 100%;'>$message</table>";
mail($admin_email, $form_subject, $message, "From: $project_name <$admin_email>" . "\r\n" . "Reply-To: $admin_email" . "\r\n" . "X-Mailer: PHP/" . phpversion() . "\r\n" . "Content-type: text/html; charset=\"utf-8\"");
Problem solved.
<form action="php/post_delete.php" method="post">
<input type = "text" name = "id" value ="' .$result['id']. '" hidden />
<input type="submit" value="Удалить"><br>
</form>';
<?php
$id = $_POST['id'];
$query = database::query("DELETE FROM punk WHERE id = '$id'");
?>
<input type = "text" name="id" value="' .$result['id']. '" hidden />
Well, not $id = $_POST['id'] but $id = $_POST['result']['id'] probably
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question