Joon Joonam Joon Joonam - 3 months ago 23
PHP Question

How to add php to wordpress form

I'm having a very hard time trying to get a php code integrated into a form I've created on wordpress. I've trying 3 different php plugins to no avail. Here is the html and css. Does anyone have any idea where I should be putting the php on wordpress and how I should properly call it through the "action" in the form?


input[type=text], input[type=number], select[name=province]{ font-family: arial; width:100%;
border: 1px solid #E5E5E5; padding: 10px 20px;}
input[name=ffirstname] {width:49%; margin-right:1%; }
input[name=lastname] {width:49%; margin-left:1%; }
input[name=address] {width:65.6667%; margin-right:1%; }
input[name=unit] {width:32.3337%; margin-left:1%; }
input[name=city] {width:49%; margin-right:1%; }
select[name=province] {width:24%; margin-left:1%;}
input[name=postal] {width:24%; margin-left:1%; }
input[name=email] {width:49%; margin-right:1%; }
input[name=phone] {width:49%; margin-left:1%;}
input[class=submit] {
background-color: #f05a28;
color: white;
padding: 8px 20px;
margin-left: 85%;
border-radius: 4px;
border: none; !important;
outline: none; !important ;
cursor: pointer;
box-shadow: none; !important;



<form name"infoform" method="post" action="form-to-email.php" >
<br><input type="text" name="ffirstname" placeholder="First Name"/><input type="text" name="lastname" placeholder="Last Name"/>
<br><br><input type="text" name="address" placeholder="Address"/><input type="text" name="unit" placeholder="Unit"/></br>
<br><input type="text" name="city" placeholder="City"/><select name="province" form="form1">
<option value="ab">AB</option>
<option value="BC">BC</option>
<option value="BC">MB</option>
<option value="NB">NB</option>
<option value="NL">NL</option>
<option value="NS">NS</option>
<option value="ON">ON</option>
<option value="PE">PE</option>
<option value="QC">QC</option>
<option value="SK">SK</option>
</select><input type="text" name="postal" placeholder="Postal Code"/></br>
<br><input type="text" name="country" placeholder="Country"/></br>
<Br><input type="text" name="email" placeholder="Email"/><input type="number" name="phone" placeholder="Phone#"/></br>
<br> <br><input type="submit" value="Next"/>



$name = $_POST['ffirstname'];
$email = $_POST['lastname'];
$message = $_POST['address'];

$to = "";
$subject = "My contact form";
$body = " You have received a new";



Usually I use footer.php to add js and php. just before the tag close of body. But if not work try use header.php maybe your code need be read before the end. The html part you can put inside a page or post without problem.

If you want use plug-in, you can use easy Contact form 7.

Check here and here for tutorial.

UPDATR - for add php code into Wordpress.

You can add the code between php tag, so open your header.php or footer.php or page.php and write your code inside the tag


Code here


In this way you will see this code in every part of Wordpress.

Header and footer are always call. If you need only in post or page use page.php or post.php