I need to upload the inserted data of the form and go to the Thank You Page on submission. I've tried some methods and I managed to only get one working, but not both.
The site on Wordpress and XAMPP. The following code just redirects, but if I remove the onsubmit attribute it will submit but won't redirect.
<script>
function redirect(){
window.location.replace("localhost/concurs/thank-you-page");
return false;
}
</script>
<?php
$x=new mysqli("localhost", "root", "");
if ($x->connect_error) {
die("Connection failed: " . $x->connect_error);
}
$y=mysqli_select_db($x,"concurs");
$Prenume = "";
$Nume = "";
$email = "";
$tel = "";
$Prenume= isset($_POST['firstname']) ? $_POST['firstname'] : '';
$Nume= isset($_POST['lastname']) ? $_POST['lastname'] : '';
$email= isset($_POST['email']) ? $_POST['email'] : '';
$tel= isset($_POST['tel']) ? $_POST['tel'] : '';
$z = "";
if($Prenume!=null && $Nume!=null && $email!=null)
$z=mysqli_query($x,"INSERT INTO concurs.wp_formular (Prenume, Nume, email, tel) VALUES ('$Prenume', '$Nume','$email', '$tel')");
mysqli_close($x);
?>
<form data-validate="parsley" data-parsley-validate="" id="myForm" method="post" action="" onsubmit="return redirect()">
<button type="submit" class="form_submit LatoBlack" id="submit">
Submit </button>
</form>