0
<?php
$name = $_POST['name'];`введите сюда код`
$email = $_POST['email'];

$dbh = new PDO('mysql:host=localhost;dbname=ck72868_n1', 'ck72868_n1', 'Ukrain');
$stmt = $dbh->prepare("INSERT INTO `order`(`time`, name, email)
    VALUES (NOW(), :name, :email)");
$stmt->bindParam(':name', $name);введите сюда код
$stmt->bindParam(':email', $email);
$stmt->execute();

echo '1';

js

$(function(){
    $(".send-button").on('click', function(){
        let request = {
            "email": $("input[name='email']").val()
        }
        $.post('api.php', request, function(response){
            if(response == '1'){
                let email = $('input[name="email"]').val('')
            }
            else{
                alert("WRONG!!!")
            }
        })
    })
})

html конец кода

                </div>
          </section>
      &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

0 Answers0