-1

Morning!

This is the email that I receive when I send a form tht I've created with catpcha, I would like to hide the section highlighted in the screenshot below, is there any possibility?

I share the code of the form.

Form

<form class="sb-form-to-hide" method="post">
                <div class="form-group sb-title">
                    <label for="title">title</label>
                    <input type="text" class="form-control" id="title" name="title">
                    <input type="hidden" id="form_subject" name="form_subject" value="<?=$form_subject?>">
                    <?php foreach ($mail_sender as $msender => $key){ ?>
                    <input type="hidden" id="email_var<?=$msender?>" name="email_var[]" value="<?=$key?>">
                    <?php } ?>
                    <input type="hidden" id="hotel_var" name="hotel_var" value="<?=$hotel?>">
                    <input type="hidden" id="language" name="language" value="<?=$G['language']?>">
                    <input type="hidden" id="testing" name="testing" value="<?=$_GET['testing']?>">
                    <label class="form_id_label" for="form_id">form id</label>
                    <input type="text" class="form_id" name="form_id">
                </div>
                <div class="form-group">
                    <label for="name"><?=$T['lbl_form_your_name']?></label>
                    <input type="text" class="form-control required" id="name" name="lbl_form_your_name">
                </div>
                <div class="form-group">
                    <label for="email"><?=$T['lbl_form_your_email']?></label>
                    <input type="email" class="form-control required email" id="email" name="lbl_form_your_email">
                </div>
                <div class="form-group">
                    <label for="message"><?=$T['lbl_form_your_message_for_us']?></label>
                    <textarea class="form-control required" id="message" rows="5" name="lbl_form_your_message_for_us"></textarea>
                </div>
                <div class="form-group checkbox">
                    <label><input type="checkbox" class="required" name="lbl_privacy_policy" value="lbl_form_yes" checked><?=$T['lbl_privacy_policy']?> (<a href="/<?=$G['language']?>/<?=$T['url_'.$hotel.'_privacy_policy']?>/" target="_blank"><?=$T['lbl_read_more']?></a>).</label>
                </div>

                <!--div class="form-group form-group-captcha">
                    <input type="text" class="hiddenRecaptcha required" name="hiddenRecaptcha" id="hiddenRecaptcha">
                </div-->
                {!--<div class="g-recaptcha" data-sitekey="<?=RECAPTCHA_SITE_KEY?>" data-callback="recaptchaCallback" data-size="invisible"></div>--}
                <div id="g-recaptcha-div"></div>

                <textarea id="confirmation" name="lbl_form_confirmation" class="hidden-xs hidden-sm hidden-md hidden-lg hidden-xl"><?=$E['F_page_extra']?></textarea>
                <button type="submit" style="width:100%;" class="btn btn-info pull-right" id="sb-submit-form"><?=$T['lbl_form_send']?></button>
            </form>

Javascript:

enter image description here

This is the source that generate the table of the response email:

# CHECK IF FORM SENT. AJAX. RESPONSE IN JAVASCRIPT TO INTERACT IN THE FORM.

if (!empty($_POST)) { $js = '';

# ALTERNATIVE CAPTCHA, IT MUST NOT BE FILLED
if (!empty($_POST['title'])) { exit; }

# FORM MAIL TO SENT
unset($_POST['title']);
unset($_POST['form_subject']);
unset($_POST['email_var']);
unset($_POST['hotel_var']);
unset($_POST['language']);
unset($_POST['lbl_privacy_policy']);
unset($_POST['lbl_form_confirmation']);
unset($_POST['submit']);

$message_top = '<html><body><a href="'.$hotel_url.'/'.$language.'/'.$G['url_segment'].'" title="'.$hotel_name.'"><img src="'.$hotel_logo.'" width="250" alt="'.$hotel_name.'" /></a>';
    
$table = '<table rules="all" width="100%" border="1" bgcolor="'.$colors[$hotel]['grey01']['hex100'].'" bordercolor="'.$colors[$hotel]['grey01']['hex'].'" cellpadding="5">';
$table .= '<tr><th colspan="2" bgcolor="'.$colors[$hotel]['success']['hex'].'" color="'.$colors[$hotel]['grey01']['hex100'].'">Form details</th></tr>';
$table .= '<tr><td color="'.$colors[$hotel]['grey01']['hex'].'"><strong>'.$T_LABELS['lbl_form_date'].'</strong></td><td color="'.$colors[$hotel]['grey01']['hex'].'">'.date("l, F j, Y, g:i a").' [GMT]</td></tr>';
foreach ($_POST as $field => $value) {
    if (!empty($value)) {
        $table .= '<tr><td color="'.$colors[$hotel]['grey01']['hex'].'"><strong>'.(!empty($T_LABELS[$field])?$T_LABELS[$field]:$field).'</strong></td><td color="'.$colors[$hotel]['grey01']['hex'].'">';
        if (is_array($value)) {
            foreach ($value as $subfield => $subvalue) {
                $table .=  " - ";
                $table .=  (!empty($T_LABELS[$subvalue])?$T_LABELS[$subvalue]:$subvalue)."<br>";
            }
        } else {
            $table .= (!empty($T_LABELS[$value])?$T_LABELS[$value]:$value);
        }
        $table .= "</td></tr>";
    }
}


$table_u = '<table rules="all" width="100%" border="1" bgcolor="'.$colors[$hotel]['grey01']['hex100'].'" bordercolor="'.$colors[$hotel]['grey01']['hex'].'" cellpadding="5">';
$table_u .= '<tr><th colspan="2" bgcolor="'.$colors[$hotel]['success']['hex'].'" color="'.$colors[$hotel]['grey01']['hex100'].'">'.$T['lbl_form_sent_successfully'].'</th></tr>';
$table_u .= '<tr><td color="'.$colors[$hotel]['grey01']['hex'].'"><strong>'.$T['lbl_form_date'].'</strong></td><td color="'.$colors[$hotel]['grey01']['hex'].'">'.date("l, F j, Y, g:i a").' [GMT]</td></tr>';
foreach ($_POST as $field => $value) {
    if (!empty($value)) {
        $table_u .= '<tr><td color="'.$colors[$hotel]['grey01']['hex'].'"><strong>'.(!empty($T[$field])?$T[$field]:$field).'</strong></td><td color="'.$colors[$hotel]['grey01']['hex'].'">';
        if (is_array($value)) {
            foreach ($value as $subfield => $subvalue) {
                $table_u .=  " - ";
                $table_u .=  (!empty($T[$subvalue])?$T[$subvalue]:$subvalue)."<br>";
            }
        } else {
            $table_u .= (!empty($T[$value])?$T[$value]:$value);
        }
        $table_u .= "</td></tr>";
    }
}

$message_bot = "</table></body></html>\n\n\n";

Any answer would be pretty appreciated.

Thanks so much, Roberto

4
  • 1
    No, which data you populate the email that you yourself are creating(?) with, is not under Google's control.
    – CBroe
    Commented Jul 15, 2022 at 7:27
  • If you share the code that creates the screen shot, someone will be able to tell you which part to remove.
    – droopsnoot
    Commented Jul 15, 2022 at 7:30
  • Anyway I doubt that code is relevant. We need to see the (presumably PHP) code which handles the form submission and generates the email.
    – ADyson
    Commented Jul 15, 2022 at 8:20

1 Answer 1

0

foreach ($_POST as $field => $value)...you are just looping through all the POST variables submitted, of which the recaptcha is one. A better approach might be to just target the specific fields you actually want to appear in the email.

Or if you're sure the recaptcha one is the only one you want to exclude, just make a special case for it:

foreach ($_POST as $field => $value) {
    if (!empty($value) && $field != "g-recaptcha-response") {

Not the answer you're looking for? Browse other questions tagged or ask your own question.