Answer the question
In order to leave comments, you need to log in
How to pass a variable in a form handler?
There is a script for sending a form on the site, in addition to the name and phone fields, it is necessary that the value of utm tags be transmitted, this is how it is written and data on utm tags is not transmitted:
if ($_POST['data']['name']['value']){$body .= 'Имя: '.$_POST['data']['name']['value'].'<br />';}
if ($_POST['data']['phone']['value']){$body .= 'Телефон: '.$_POST['data']['phone']['value'].'<br />';}
if ($email){$body.= "utm_source: $utm_source<br />";}
if ($email){$body.= "utm_medium: $utm_medium<br />";}
if ($email){$body.= "utm_campaign: $utm_campaign<br />";}
if ($email){$body.= "utm_term: $utm_term<br />";}
if ($email){$body.= "utm_content: $utm_content<br />";}
if ($name){$body.= "Имя: $name<br />";}
if ($phone){$body.= "Телефон: $phone<br />";}
if ($email){$body.= "utm_source: $utm_source<br />";}
if ($email){$body.= "utm_medium: $utm_medium<br />";}
if ($email){$body.= "utm_campaign: $utm_campaign<br />";}
if ($email){$body.= "utm_term: $utm_term<br />";}
if ($email){$body.= "utm_content: $utm_content<br />";}
Answer the question
In order to leave comments, you need to log in
Add hidden fields to the form that will pull labels from the address bar:
<input type="hidden" name="utm_term" value="<?php echo isset($_GET['utm_term']) ? $_GET['utm_term'] : '' ;?>">
<input type="hidden" name="utm_campaign" value="<?php echo isset($_GET['utm_source']) ? $_GET['utm_campaign'] : '' ;?>">
<input type="hidden" name="utm_content" value="<?php echo isset($_GET['utm_content']) ? $_GET['utm_content'] : '' ;?>">
<input type="hidden" name="utm_source" value="<?php echo isset($_GET['utm_source']) ? $_GET['utm_source'] : '' ;?>">
<input type="hidden" name="utm_medium" value="<?php echo isset($_GET['utm_medium']) ? $_GET['utm_medium'] : '' ;?>">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question