Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

add a field to this contact form

Ads
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#1
Member
Hello
I used page manager and with these codes :

Code:
<?php

global $headerinclude, $header, $theme, $footer, $templates, $lang;

$lang->load('member');
$lang->load('messages');
$lang->load('datahandler_user');

$subject = htmlspecialchars_uni(trim($mybb->input['subject']));
$message = htmlspecialchars_uni(trim($mybb->input['message']));

if(!$mybb->user['uid'])
{
    $name = htmlspecialchars_uni(trim($mybb->input['name']));
    $email = htmlspecialchars_uni(trim($mybb->input['email']));

    $usertemplate = '<tr>
<td width="40%" class="trow1"><strong>{$lang->full_name}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="name" value="{$name}" /></td>
</tr>
<tr>
<td width="40%" class="trow2"><strong>{$lang->email_address}</strong></td>
<td width="60%" class="trow2"><input type="text" class="textbox" size="50" name="email" value="{$email}" /></td>
</tr>
<tr>';

    $usertemplate = str_replace("\'", "'", addslashes($usertemplate));

    eval("\$usertemplate = \"" . $usertemplate . "\";");
}
else
{
    $name = $mybb->user['username'];
    $email = $mybb->user['email'];

    eval("\$usertemplate = \"" . $templates->get('changeuserbox') . "\";");
}

if($mybb->input['action'] == 'do_email' && $mybb->request_method == 'post')
{
    verify_post_check($mybb->input['my_post_key']);

    if(empty($name))
    {
        $errors[] = $lang->userdata_missing_username;
    }
    elseif(strpos($name, '<') !== false || strpos($name, '>') !== false || strpos($name, '&') !== false || my_strpos($name, '\\') !== false || strpos($name, ';') !== false || strpos($name, ',') !== false)
    {
        $errors[] = $lang->userdata_bad_characters_username;
    }

    if(empty($email))
    {
        $errors[] = $lang->userdata_missing_email;
    }
    elseif(!validate_email_format($email))
    {
        $errors[] = $lang->userdata_invalid_email_format;
    }

    if(empty($subject))
    {
        $errors[] = $lang->error_no_email_subject;
    }

    if(empty($message))
    {
        $errors[] = $lang->error_no_email_message;
    }

    if($mybb->settings['captchaimage'] == 1 && function_exists("imagepng") && !$mybb->user['uid'])
    {
        $imagehash = $db->escape_string($mybb->input['imagehash']);
        $imagestring = $db->escape_string($mybb->input['imagestring']);
        $query = $db->simple_select('captcha', '*', 'imagehash="' . $imagehash . '"');
        $imgcheck = $db->fetch_array($query);
        if(my_strtolower($imgcheck['imagestring']) != my_strtolower($imagestring) || !$imgcheck['imagehash'])
        {
            $errors[] = $lang->error_regimageinvalid;
        }
        $db->delete_query('captcha', 'imagehash="' . $imagehash . '"');
    }

    if(count($errors) == 0)
    {
        if($mybb->settings['mail_handler'] == 'smtp')
        {
            $from = $email;
        }
        else
        {
            $from = $name . '<' . $email . '>' ;
        }
        my_mail($mybb->settings['adminemail'], '[' . $mybb->settings['bbname'] . ' ' . $pages['name'] . '] ' . $subject, $message, $from, '', '', false, 'text', '', $email);

        redirect($mybb->settings['bburl'], $lang->redirect_emailsent);
    }
    else
    {
        $errors = inline_error($errors);
    }
}

if($mybb->settings['captchaimage'] == 1 && function_exists('imagepng') && !$mybb->user['uid'])
{
    $randomstr = random_str(5);
    $imagehash = md5(random_str(12));
    $imagearray= array(
        'imagehash' => $imagehash,
        'imagestring' => $randomstr,
        'dateline' => TIME_NOW
    );
    $db->insert_query('captcha', $imagearray);
    eval("\$captcha = \"" . $templates->get('post_captcha') . "\";");
}

$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder">
<thead>
<tr>
<td colspan="2" class="thead">
<strong>' . $pages['name'] . '</strong>
</td>
</tr>
</thead>
<tbody>
{$usertemplate}
<tr>
<td width="40%" class="trow1"><strong>{$lang->email_subject}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="subject" value="{$subject}" /></td>
</tr>
<tr>
<td valign="top" width="40%" class="trow2"><strong>{$lang->email_message}</strong></td>
<td width="60%" class="trow2"><textarea cols="50" rows="10" name="message">{$message}</textarea></td>
</tr>
{$captcha}
</tbody>
</table>
<br />
<input type="hidden" name="action" value="do_email" />
<div align="center"><input type="submit" class="button" value="{$lang->send_email}" /></div>
</form>
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>

Now I want to add another filed to this contact form
Could you help how can I do it ?

Heart
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#2
Support Team
What field would you like to add?
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#3
Member
a field for adding number
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#4
Support Team
You mean like phone number? So the field has to be limited only to number inputs right?

I have created a new input field called Phone Number but I am not sure if it sends correct email cause I can't test it on localhost. Please do it for me!

PHP Code:
<?php

global $headerinclude$header$theme$footer$templates$lang;

$lang->load('member');
$lang->load('messages');
$lang->load('datahandler_user');

$subject htmlspecialchars_uni(trim($mybb->input['subject']));
$number htmlspecialchars_uni(trim($mybb->input['number']));
$message htmlspecialchars_uni(trim($mybb->input['message']));

if(!
$mybb->user['uid'])
{
    
$name htmlspecialchars_uni(trim($mybb->input['name']));
    
$email htmlspecialchars_uni(trim($mybb->input['email']));

    
$usertemplate '<tr>
<td width="40%" class="trow1"><strong>{$lang->full_name}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="name" value="{$name}" /></td>
</tr>
<tr>
<td width="40%" class="trow2"><strong>{$lang->email_address}</strong></td>
<td width="60%" class="trow2"><input type="text" class="textbox" size="50" name="email" value="{$email}" /></td>
</tr>
<tr>'
;

    
$usertemplate str_replace("&#092;'""'"addslashes($usertemplate));

    eval(
"&#092;$usertemplate = &#092;"" $usertemplate "&#092;";");
}
else
{
    
$name $mybb->user['username'];
    
$email $mybb->user['email'];

    eval(
"&#092;$usertemplate = &#092;"" $templates->get('changeuserbox') . "&#092;";");
}

if(
$mybb->input['action'] == 'do_email' && $mybb->request_method == 'post')
{
    
verify_post_check($mybb->input['my_post_key']);

    if(empty(
$name))
    {
        
$errors[] = $lang->userdata_missing_username;
    }
    elseif(
strpos($name'<') !== false || strpos($name'>') !== false || strpos($name'&') !== false || my_strpos($name'&#092;&#092;') !== false || strpos($name';') !== false || strpos($name',') !== false)
    {
        
$errors[] = $lang->userdata_bad_characters_username;
    }

    if(empty(
$email))
    {
        
$errors[] = $lang->userdata_missing_email;
    }
    elseif(!
validate_email_format($email))
    {
        
$errors[] = $lang->userdata_invalid_email_format;
    }

    if(empty(
$subject))
    {
        
$errors[] = $lang->error_no_email_subject;
    }

    if(empty(
$message))
    {
        
$errors[] = $lang->error_no_email_message;
    }
    
    if(empty(
$number) || !is_numeric($number))
    {
        
$errors[] = "Phone Number is missing or invalid!";
    }

    if(
$mybb->settings['captchaimage'] == && function_exists("imagepng") && !$mybb->user['uid'])
    {
        
$imagehash $db->escape_string($mybb->input['imagehash']);
        
$imagestring $db->escape_string($mybb->input['imagestring']);
        
$query $db->simple_select('captcha''*''imagehash="' $imagehash '"');
        
$imgcheck $db->fetch_array($query);
        if(
my_strtolower($imgcheck['imagestring']) != my_strtolower($imagestring) || !$imgcheck['imagehash'])
        {
            
$errors[] = $lang->error_regimageinvalid;
        }
        
$db->delete_query('captcha''imagehash="' $imagehash '"');
    }

    if(
count($errors) == 0)
    {
        if(
$mybb->settings['mail_handler'] == 'smtp')
        {
            
$from $email;
        }
        else
        {
            
$from $name '<' $email '>' ;
        }
        
my_mail($mybb->settings['adminemail'], '[' $mybb->settings['bbname'] . ' ' $pages['name'] . '] ' $subject$number$message$from''''false'text'''$email);

        
redirect($mybb->settings['bburl'], $lang->redirect_emailsent);
    }
    else
    {
        
$errors inline_error($errors);
    }
}

if(
$mybb->settings['captchaimage'] == && function_exists('imagepng') && !$mybb->user['uid'])
{
    
$randomstr random_str(5);
    
$imagehash md5(random_str(12));
    
$imagearray= array(
        
'imagehash' => $imagehash,
        
'imagestring' => $randomstr,
        
'dateline' => TIME_NOW
    
);
    
$db->insert_query('captcha'$imagearray);
    eval(
"&#092;$captcha = &#092;"" $templates->get('post_captcha') . "&#092;";");
}

$template '<html>
<head>
<title>' 
$pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<form action="' 
$_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="' 
$theme['borderwidth'] . '" cellpadding="' $theme['tablespace'] . '" class="tborder">
<thead>
<tr>
<td colspan="2" class="thead">
<strong>' 
$pages['name'] . '</strong>
</td>
</tr>
</thead>
<tbody>
{$usertemplate}
<tr>
<td width="40%" class="trow1"><strong>{$lang->email_subject}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="subject" value="{$subject}" /></td>
</tr>
<tr>
<td width="40%" class="trow1"><strong>Phone Number</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="number" value="{$number}" /></td>
</tr>
<tr>
<td valign="top" width="40%" class="trow2"><strong>{$lang->email_message}</strong></td>
<td width="60%" class="trow2"><textarea cols="50" rows="10" name="message">{$message}</textarea></td>
</tr>
{$captcha}
</tbody>
</table>
<br />
<input type="hidden" name="action" value="do_email" />
<div align="center"><input type="submit" class="button" value="{$lang->send_email}" /></div>
</form>
{$footer}
</body>
</html>'
;

$template str_replace("&#092;'""'"addslashes($template));

add_breadcrumb($pages['name']);

eval(
"&#092;$page = &#092;"" $template "&#092;";");

output_page($page);

?>
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#5
Member
message and number has been replaced

the email is like this :
Quote:message@....
to : .....
123
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#6
Support Team
What are you saying is it working or not?
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#7
Member
that's working
but when I send a message , the structure is like this :

Quote:my message@wwww.com
to : .....
123

the message has been replaced with username
and its not beside the number or after it
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#8
Support Team
In admin control panel please replace admin email with the one I will PM you and then use that page to send me an email.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#9
Member
(07-22-2014 09:01 PM)marcus_avrelius Wrote:  In admin control panel please replace admin email with the one I will PM you and then use that page to send me an email.

I did it
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#10
Support Team
I am still working on it please be patient.
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#11
Support Team
After spending quite a bit of time on this I came to the conclusion that it will require a lots of core file modifications in order to add new filed and still use MYBB email sending function.

However there is a way simply by using your own send email class here is an example: http://www.freecontactform.com/email_form.php





User(s) browsing this thread: 1 Guest(s)