I’m doing a contact form in wordpress, this is a template page, in this page there is also a google map, this map get coordinates from php variables that I can set in the admin panel of wordpress.
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/contact-form/map.js"></script>
<script type="text/javascript">
var lat=<?php echo($GLOBALS['desklab_theme_settings']['latcord_text']);?>;
var lng=<?php echo($GLOBALS['desklab_theme_settings']['lngcord_text']);?>;
generateMap(lat,lng);
</script>
I’ ve done so, as advised in another question that I wrote
The problem is that I must get variables in this php file, so I must to the same with email
<?php
/*
Template Name: ContactForm
*/
?>
<?php get_header(); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var emailto=<?php echo($GLOBALS['desklab_theme_settings']['email_text']);?>;
</script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/contact-form/contactform.js"></script>
The problem is that I can’ t do the same of map, becuase the js of contact form start at click of contact form’s button
<input class="btn" type="button" id="button-contact" value="Send" />
js:
$(document).ready(function() {
//click of form bottom
$("#bottone-contact").click(function(){
After that I go in another PHP file that send email (js)
$.ajax({
type: "POST",
url: "wp-content/themes/DeskLab/contact-form/mail.php",
PHP mail.php
<?php
session_start();
$nome = $_POST['nome'];
$email = $_POST['email'];
How can I do and how can I add the variable emailto in the php? Thank you!
I’m not sure I understand what you mean exactly, but if I understand you correctly, something like this could work. Inside of your form, put a hidden field with your email from server: