this code works with php but how to use it for wordpress?
Hope you can help me! iam currently learing to build a wordpress site from the scratch. But this is not working for some reason

<?php

/*
  Template Name: inlog
*/
  ?>
  <!-- Form -->

  <!-- After the user fills in the form, the application wil check if it already exists -->
  <!-- If it already exitsts the user will get the option to get directed to the result page -->
  <!-- Else the user will get directed to the band form -->

  <form method="POST" class="main_form" action="">
    <div class="main_form_input">

      <input type="text" name="name" required placeholder="Username">
      <input type="text" name="email" required placeholder="Email">

    </div>

      <input type="submit" name="Submit" value="Log In">

  </form>

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){


    mysql_connect('localhost', 'root', '');
    mysql_select_db('td-game.com');




// Get values from form 
$name=$_POST['name'];
$email=$_POST['email'];

// Insert data into mysql 
$sql="INSERT INTO klant(naam, email, date) VALUES ('$name', '$email', Now())";
$result=mysql_query($sql);

 header("Location: ./pages/voting_page.php");

}?>

Read more here: how to transfer mysqli to wordpress?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: