0

Не получаю в бд данные которые указываю при регистрации, не могу найти проблему вот весь код что есть. registration.php

<!DOCTYPE html>
<html>
<head>
<title>Registration Form Using jQuery - Demo Preview</title>
<meta name="robots" content="noindex, nofollow">
<!-- Include CSS File Here -->
<link rel="stylesheet" href="style.css"/>
<!-- Include JS File Here -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div class="form">
<form autocomplete="off" id="myform">

<h2>Create Registration Form Using jQuery</h2> <label>Name :</label> <input type="text" name="name" id="name"> <label>Email :</label> <input type="text" name="email" id="email"> <label>Password :</label> <input type="password" name="password" id="password">

<input type="submit" name="register" id="login" value="login"> </form> </div> <script type="text/javascript"> $(document).ready(function(){ $("#myform").on('submit', function(e){ e.preventDefault();

            $.ajax({
              type: &quot;POST&quot;,
              url: &quot;register.php&quot;,
              data: new FormData(this),
              dataType: &quot;json&quot;,
              contentType: false,
              cashe: false,
              processData: false,
              success:function(response){
                $(&quot;.form-message&quot;).css(&quot;display&quot;, &quot;block&quot;);

                if(response.status == 1){
                  $(&quot;#myform&quot;)[0].reset();
                  $(&quot;.form-message&quot;).html('&lt;p&gt;' + response.message + '&lt;/p&gt;');
                }else{

                  $(&quot;.form-message&quot;).css(&quot;display&quot;, &quot;block&quot;);
                    $(&quot;.form-message&quot;).html('&lt;p&gt;' + response.message + '&lt;/p&gt;');
                }
         }

            });
        });
          });

&lt;/script&gt;
&lt;/body&gt;

</html>

register.php

<?php

$response = array ( 'status' => 0, 'message' => 'Fail'); $errorEmpty = false; $errorEmail = false;

if(isset($_POST['name']) || isset($_POST['email']) || isset($_POST['password'])){ $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; } $hash = md5($password); $check = "SELECT * FORM registration WHERE email = '$email'"; $r = mysqli_query($con, $check); $query = "INSERT INTO registration (name,email,password) VALUES('$name' , '$email' , '$password')";

?>

config.php

<?php
$con = new mysqli('localhost','root','root','college');
$con->query("INSERT INTO `register` (`name` ,`email` ,`password`) VALUES('$name' , '$email' , '$password')");

$con->close(); ?>

0 Answers0