I’ve created a kind and the desk within the database I would like submissions to be despatched to. From my analysis I’ve discovered that this code ought to ship it to the database:
<?php /* PHP code that processes kind */
if(isset($_POST['submit'])){
world $wpdb;
$tablename = Form_Submissions;
$knowledge=array(
'FirstName' => $_POST['fname'],
'LastName' => $POST['lname'],
'Consent' => $POST['consent']
);
$format = array(
'%s',
'%s',
'%s'
);
$wpdb -> insert($tablename, $knowledge, $format);
echo '<script kind="text/javascript"> doc.getElementById("frm").type.show="none"; </script>';
}
?>
Nevertheless, nothing is going on. I am at full loss on the place to go from right here. Am I lacking one thing easy, or am I utterly off beam? Thanks to your assist!
Right here is the code for the shape and the code that prompts the shape simply in case.
<html>
<type>
/* Stylings for Heading Assertion */
.h3{
text-align: middle;
font-size: 24px;
padding: 10px;
colour: white;
}
/* Stylings for checkbox */
.field{
font-size: 22px;
padding: 20px;
colour: white;
}
/* Stylings for enter labels (names and checkbox labels) */
.input-label{
text-align: middle;
font-size: 22px;
padding: 10px;
colour: white;
}
/* Button used to open the contact kind - fastened on the backside of the web page */
.open-button {
width: 170px;
peak: 60px;
background-color: clear;
define: none;
place: relative;
left: -168px;
high: 20px;
}
/* The popup kind - hidden by default */
.form-popup {
show: none;
place: absolute;
high: 25%;
left: -530px;
border: none;
z-index: 9;
background-color: #1e1e1e;
width: 1000px;
padding: 20px;
border-radius: 20px;
text-align: middle;
}
/* Units type and dimension of enter fields */
.form-popup enter[type=text] {
width: 30%;
padding: 5px;
margin: 5px 0 22px 0;
border: none;
background: #FFFFFF;
}
/* Units colour and elegance of the enter containers when chosen */
.form-popup enter:focus {
background-color: #FFFFFF;
define: none;
}
/* Stylings of the submit button */
.btn {
background-color: #DB2600;
border-radius: 9999px;
font-size: 24px;
width: 120px;
peak: 45px;
transition: 0.3s;
colour: white;
}
/* Adjustments the colour of the sugmit button when curser hovers over it */
.btn:hover {
opacity: 1;
background-color: #000000;
}
/* Hides the default checkbox */
.field enter {
place: absolute;
opacity: 0;
cursor: pointer;
peak: 0;
width: 0;
}
/* creates customized checkbox */
.checkmark {
place: absolute;
peak: 20px;
width: 20px;
background-color: white;
border-radius: 2px;
}
/* Units the colour of checkbox when checked */
.field enter:checked ~ .checkmark {
background-color: #DB2600;
}
/* creates checkmark inside checkbox */
.checkmark:after {
content material: "";
place: absolute;
show: none;
}
/* Shows checkmark when checkbox is clicked */
.field enter:checked ~ .checkmark:after {
show: block;
}
/* Positions and types checkmark */
.field .checkmark:after {
left: 7px;
high: 3px;
width: 6px;
peak: 12px;
border: strong white;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
rework: rotate(45deg);
}
/* Column formatting for checkbos and assertion. That is what's aligning the 2 gadgets. */
.column1 {
float: left;
width: 26%;
}
.column2 {
float: left;
width: 74%;
margin-top:-5px;
}
/* Clears floats after the columns */
.row:after {
content material: "";
show: desk;
clear: each;
}
</type>
<physique>
<!-- Code for the shape -->
<div class="form-popup" id="Form">
<kind methodology="post">
<!-- acknolwdgement statment -->
<h3 class="h3">kind assertion</h3>
<!-- label and enter for First Title -->
<label for="fname" class="input-label">First identify:</label>
<enter kind="text" identify="fname" required/>
<!-- label and enter for Final Title -->
<label for="lname" class="input-label">    Final identify:</label>
<enter kind="text" identify="lname" required/> <br> <br>
<!-- checkbox and label, positioned to columns to attain desired formating -->
<div class="row">
<div class="column1" type="text-align: right;">
<label class="box" type="border-color: red;">
<enter kind="checkbox" identify="consent" worth="agree" class="box" required/>
<span class="checkmark"></span>
</label></div>
<div class="column2" type="text-align: left;">
<label class="input-label"> I've learn and perceive the above assertion.
</label>
</div>
</div>
<br><br>
<!-- Submit Button -->
<enter kind="submit" identify="submit" worth="Submit" class="btn">
</kind>
</div>
<script>
operate openForm() { /* Opens Consent Type */
doc.getElementById("Form").type.show = "block";
}
</script>
</physique>
<?php /* PHP code that processes kind */
if(isset($_POST['submit'])){
world $wpdb;
$tablename = Form_Submissions;
$knowledge=array(
'FirstName' => $_POST['fname'],
'LastName' => $POST['lname'],
'Consent' => $POST['consent']
);
$format = array(
'%s',
'%s',
'%s'
);
$wpdb -> insert($tablename, $knowledge, $format);
echo '<script kind="text/javascript"> doc.getElementById("frm").type.show="none"; </script>';
}
?>
</html>
The Change Case that prompts it:
<?php /* code for pop-up button circumstances */
$host = 'https://' .$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; /* will get the present web page's URL */
change ( $host ){
case 'https://example1.com':
case 'https://example2.com':
case 'https://example3.com':
require 'pop-up-button.php'; /*calls the PHP file containing the code for the shape*/
echo '<button id="close" class="open-button" onclick="openForm()"></button>';
break;
default : /* the default case leaves the operate and permits all pages with URL's not match the circumstances to run as regular pages */
break;
}; ?>