contact page form but no subject

Discussion in 'General PHP' started by skyhigh, Mar 8, 2018.

  1. skyhigh

    skyhigh Member

    Joined:
    Sep 28, 2010
    Messages:
    446
    Likes Received:
    8
    i have this contact page it working but no subejct when i recieve email
    contact.php
    PHP:
    <?php


    include 'common.php';

    // check recaptcha is enabled
    // check recaptcha is enabled
    if ($system->SETTINGS['spam_sendtofriend'] == 2)
    {
        include 
    PACKAGE_PATH 'recaptcha/recaptcha.php';
    }
    elseif (
    $system->SETTINGS['spam_sendtofriend'] == 1)
    {
        include 
    PACKAGE_PATH 'captcha/securimage.php';
    }

    if (isset(
    $_REQUEST['id']))
    {
        
    $_SESSION['CURRENT_ITEM'] = $_REQUEST['id'];
    }

    $id intval($_SESSION['CURRENT_ITEM']);

    $TPL_error_text '';
    $emailsent 1;
    // Get item data
    $query "SELECT * FROM " $DBPrefix "auctions
    WHERE id = :auc_id"
    ;
    $params = array();
    $params[] = array(':auc_id'$id'int');
    $db->query($query$params);
    if (
    $db->numrows() > 0)
    {
        
    $auction_data $db->result();
        
    $TPL_item_title htmlspecialchars($auction_data['title']);
    }

    $spam_html '';
    if (
    $system->SETTINGS['spam_sendtofriend'] == 1)
    {
        
    $resp = new Securimage();
        
    $spam_html $resp->getCaptchaHtml();
    }

    if (isset(
    $_POST['action']) && $_POST['action'] == 'sendmail')
    {
        
    // check errors
        
    if (empty($_POST['sender_name']) || empty($_POST['sender_email']) || empty($_POST['friend_name']) || empty($_POST['friend_email']))
        {
            
    $TPL_error_text $ERR_031;
        }

        if (!
    preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i'$_POST['sender_email']) || !preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i'$_POST['friend_email']))
        {
            
    $TPL_error_text $ERR_008;
        }

        if (
    $system->SETTINGS['spam_sendtofriend'] == 2)
        {
            
    $resp recaptcha_check_answer($system->SETTINGS['recaptcha_private'], $_POST['g-recaptcha-response']);
            if (!
    $resp)
            {
                
    $TPL_error_text $MSG['752'];
            }
        }
        elseif (
    $system->SETTINGS['spam_sendtofriend'] == 1)
        {
            if (!
    $resp->check($_POST['captcha_code']))
            {
                
    $TPL_error_text $MSG['752'];
            }
        }

        

        if (!empty(
    $TPL_error_text))
        {
            
    $emailsent 1;
        }
        else
        {
            
    $emailsent 0;
            
    $emailer = new email_handler();
            
    $emailer->assign_vars(array(
                    
    'S_NAME' => $_POST['sender_name'],
                    
    'S_EMAIL' => $_POST['sender_email'],
                    
    'S_COMMENT' => $_POST['sender_comment'],
                    
    'F_NAME' => $_POST['friend_name'],
                    
    'TITLE' => $TPL_item_title,
                    
    'URL' => $system->SETTINGS['siteurl'] . 'game.php?id=' $id,
                    
    'SITENAME' => $system->SETTINGS['sitename'],
                    
    'SITEURL' => $system->SETTINGS['siteurl'],
                    
    'ADMINEMAIL' => $system->SETTINGS['adminmail']
                    ));
            
    $emailer->email_sender($_POST['friend_email'], 'contactus.inc.php'$MSG['90555']);
            
    header('Location: contactussent.php');
        }
    }

    if (
    $system->SETTINGS['spam_sendtofriend'] == 2)
    {
        
    $capcha_text recaptcha_get_html($system->SETTINGS['recaptcha_public']);
    }
    elseif (
    $system->SETTINGS['spam_sendtofriend'] == 1)
    {
        
    $capcha_text $spam_html;
    }

    $template->assign_vars(array(
            
    'ERROR' => $TPL_error_text,
            
    'ID' => intval($_REQUEST['id']),
            
    'CAPTCHATYPE' => $system->SETTINGS['spam_register'],
            
    'CAPCHA' => (isset($capcha_text)) ? $capcha_text '',
            
    'TITLE' => $TPL_item_title,
            
    'FRIEND_NAME' => (isset($_POST['friend_name'])) ? $_POST['friend_name'] : '',
            
    'FRIEND_EMAIL' => (isset($_POST['friend_email'])) ? $_POST['friend_email'] : '',
            
    'YOUR_NAME' => ($user->logged_in) ? $user->user_data['name'] : '',
            
    'YOUR_EMAIL' => ($user->logged_in) ? $user->user_data['email'] : '',
            
    'COMMENT' => (isset($_POST['sender_comment'])) ? $_POST['sender_comment'] : '',
            
    'EMAILSENT' => $emailsent
            
    ));

    include 
    'header.php';
    $template->set_filenames(array(
            
    'body' => 'contactus.tpl'
            
    ));
    $template->display('body');
    include 
    'footer.php';

    ?>

    tpl
    PHP:
    <div class="row">
        <
    div class="col-md-8 col-md-offset-2">
            <
    legend>Contact us</legend>
            
    <!-- IF 
    EMAILSENT eq '' -->
            <
    div class="alert alert-success" role="alert">
                <
    p>
                    <
    b>{L_017} : {TITLE}</b><br>
                    <
    b>{L_146} {FRIEND_EMAIL}</b>
                </
    p>
            </
    div>
    <!-- ELSE -->
        <!-- IF 
    ERROR ne '' -->
            <
    div class="alert alert-danger" role="alert">
                {
    ERROR}
            </
    div>
        <!-- ENDIF -->
            <
    div class="well">
                <
    form class="form-horizontal" name="friend" action="contactus.php" method="post">
                    <
    input type="hidden" name="csrftoken" value="{_CSRFTOKEN}">
                    <
    div class="alert alert-info" role="alert">{TITLE}</div>
                    <
    div class="hide form-group">
                        <
    label class="col-sm-3 control-label">{L_140}</label>
                        <
    div class="col-sm-9"><input type="text" name="friend_name" class="form-control" value="Contact us"></div>
                    </
    div>
                    <
    div class="hide form-group">
                        <
    label class="col-sm-3 control-label">{L_141}</label>
                        <
    div class="col-sm-9"><input name="friend_email" type="text" class="form-control" value="{FRIEND_EMAIL}" readonly="true"></div>
                    </
    div>
                    <
    div class="form-group">
                        <
    label class="col-sm-3 control-label">{L_003}</label>
                        <
    div class="col-sm-9"><input type="text" name="sender_name" required="required" placeholder="your name" class="form-control"></div>
                    </
    div>
                    <
    div class="form-group">
                        <
    label class="col-sm-3 control-label">{L_143}</label>
                        <
    div class="col-sm-9"><input type="text" name="sender_email" class="form-control" required="required" placeholder="your email"></div>
                    </
    div>
                    <
    div class="form-group">
                        <
    div class="capchabox2">{CAPCHA}</div>
                    </
    div>
                    <
    div class="form-group">
                        <
    label class="col-sm-3 control-label">{L_144}</label>
                        <
    div class="col-sm-9">
                            <
    textarea name="sender_comment" class="form-control" rows="6">{COMMENT}</textarea>
                        </
    div>
                    </
    div>
                    <
    div class="form-group">
                        <
    div class="text-center">
                            <
    input type="hidden" name="id" value="{ID}">
                            <
    input type="hidden" name="item_title" value="{TITLE}">
                            <
    input type="hidden" name="action" value="sendmail">
                            <
    input type="submit" name="" value="{L_5201}" class="btn btn-primary">
                        </
    div>
                    </
    div>
                </
    form>
            </
    div>
    <!-- ENDIF -->
        </
    div>
    </
    div>
     

Share This Page