- Автор темы
- #1
Всем привет, есть форма регистрации, которая делает запись в базу данных, как сделать чтобы при нажатии кнопки "отправить", копия (имя, фамилия, почта, телефон и т.д.) отправлялось на эмайл?
вот исходный код страницы:
вот исходный код страницы:
Код:
<?php
/**
*
* @package Invent
* @subpackage Template
*/
/*
*/
###############################################################################################################
session_start();
unset($_SESSION['USER_DATA'],$header_template,$footer_template,$message);
define( 'PAGENAME', $wp->query_vars['pagename'] );
define( 'PAGE_LINK', get_page_link($post->ID) );
$obj = Geo::get_geo_obj($mysql,ICL_LANGUAGE_CODE);
if ($_GET['action']=='registr'){
$result=' ';
unset($user);
$user->pkod1 = intval($_POST['pkod1']);
$user->pkod2 = intval($_POST['pkod2']);
$user->pkod = $_POST['pkod'];
$user->name = slash($_POST['student_name'],1);
$user->sname = slash($_POST['student_sname'],1);
$user->search_name = process_word_for_search($user->name);
$user->search_sname = process_word_for_search($user->sname);
#######################################################
$user->tel = slash($_POST['tel'],1);
$user->email = slash($_POST['email'],1);
$user->comments = slash($_POST['comments'],1);
##################
$user->ccid1 = intval($_POST['ccid1']);
$user->ccid2 = intval($_POST['ccid2']);
$user->obj1 = intval($_POST['cid_0']);
$user->obj2 = intval($_POST['cid_1']);
##################
if ($dr_uid) $user->dr_uid = $dr_uid;
if( !preg_match( '/^[._a-z0-9-]+@[._a-z0-9-]+\.[a-z]{2,4}$/i', $user->email ) ) {
die(__('Specify yours e-mail!','zapis').'<script>D.getElementById("button_add").disabled = false;</script>');
}
if( !preg_match( '/^[0-9-]+$/', $user->pkod)) {
$user->pkod = 0;
}
if (!$user->name or !$user->sname or !$user->tel or ($user->obj1 <= 0) or ( $user->obj2 <= 0 and $user->ccid1==1 ))
die(_e('Fill in the Form!','zapis').'<script>D.getElementById("button_add").disabled = false;</script>');
###############
if(preg_match('/666/i', $user->email) or preg_match('/devil/i',$user->email)){
die(__('Please, enter another e-mail address!','zapis').'<script>D.getElementById("button_add").disabled = false;</script>');
}
$tel = str_replace('666','xxx',$user->tel);
if (strcasecmp($_SESSION['SCODE'], $_POST['scode']) != 0 )
die(__('Incorrect code!','ask-question').'<script>D.getElementById("button_add").disabled = false;</script>');
###############
$user->u_id = VSKzapis::registr_user ($mysql, $user);
if ($user->u_id){
unset($_SESSION['SCODE']);
$result.='<span class="green">'.__('Thank you, application sent!','zapis').'</span>';
$result.='<script>D.registration.reset(); D.getElementById("button_add").disabled = false;
D.getElementById("scode").src="/wp-content/themes/invent/lib/capcha/index.php?"+(new Date()).getTime();</script>';
if ($dr_uid){
$draugiem->addActivity(__('activity-message-text','dr-pieteikt'),__('activity-message-prefix','dr-pieteikt'),false,$app_page_id);
}
} else {
$result.=__('error','zapis');
$result.='<script>D.getElementById("button_add").disabled = false;</script>';
}
die($result);
}
if ($_GET['action']=='check'){
$result=' ';
$email = $_GET['e'];
$res=0;
if( !preg_match( '/^[._a-z0-9-]+@[._a-z0-9-]+\.[a-z]{2,4}$/i', $email ) ) $res=1;
else $output = @exec("/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/sav ".escapeshellarg($email), $results, $res);
$result.= '<script>D.getElementById("email").style.color="'.($res>0?'red':'black').'";</script>';
die($result);
}
$country = $_SESSION['COUNTRY']?$_SESSION['COUNTRY']:Geo::get_country_by_ip($mysql,$_SERVER['REMOTE_ADDR']);
$_SESSION['COUNTRY'] = $country;
if ($country->code) $user_country = Geo::get_geo_obj_data($mysql, ICL_LANGUAGE_CODE, 0, $country->code);
$mysql->db_close( );
##################################################################################################################
?>
<?php
get_header($header_template);
$ask_page = $GLOBALS['ask_page'];
?>
<div id="main">
<div class="left col">
<div class="container">
<?php get_sidebar(); ?>
</div>
</div>
<div class="container">
<?endif;?>
<!-- CONTENT -->
<div style="float:right; margin-right: -9%;" id="content">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php $H1 = get_post_meta( $post->ID, 'H1',true); ?>
<? if ($draugiem_app==1):?>
<div class="links-top">
<a href="#" onclick="go('<?php echo get_page_link($ask_page->ID);?>',1,1,650,360,1,1); return false" title="<?php echo $ask_page->post_title;?>"><?php echo $ask_page->post_title;?></a>
</div>
<? endif;?>
<h1><?php if (strlen($H1)) echo $H1; else the_title(); ?></h1>
<div class="clear"></div>
<div class="entry-content">
<?
if ($draugiem_app && $message):
echo $message;
else:
the_content();
endif;
?>
</div><!-- .entry-content -->
<?php endwhile; ?>
<? if (!$message):?>
<!-- -->
<div id="result_info" class="results red"></div>
<div class="pieteiksanas">
<form action="<? echo PAGE_LINK;?>?action=registr" method="post" name="registration" onsubmit="return false;">
<input type=hidden value=0 name=ccid1 />
<input type=hidden value=0 name=ccid2 />
<div id="registr_form" class="registration registr-page">
<div id="form-area">
<div class="form">
<div id="reg-form-step1">
<label><?php _e('Name:','zapis')?><span class="red">*</span></label>
<input class="in2" type=text name="student_name">
<?php _e('Surname:','zapis')?><span class="red">*</span>
<input class="in2" type=text name="student_sname">
<!--
<?php echo __('Identity Number:','zapis') ?><span class="red">*</span>
<input class="in2" type=text name="pkod" onKeyPress ="check_val(event,this.value)" maxlength="20">
-->
<?php _e('Phone:','zapis')?><span class="red">*</span>
<input class="in2" type=text name="tel">
<?php _e('Your E-mail:','zapis')?><span class="red">*</span>
<input class="in2" type=text name="email" id="email" onblur="ajax_go('<? echo PAGE_LINK;?>?action=check&e='+this.value,'result_mail','rewrite');"> <span id="result_mail" style="display:none;"></span>
<?php _e('Country:','zapis')?><span class="red">*</span>
<div id="cdiv_0">
<select class="in2" onchange="load_selects( 1, this[this.selectedIndex].value )" name="cid_0"><option selected></option></select>
</div>
<div id="cdname_1"></div>
<div style="visibility:hidden; display:none;" id="cdiv_1">
<select class="in2" name="cid_1"><option selected></option></select>
</div>
<br />
<div><input class="in2" type=text name="scode" onfocus="set_val(this,1)" onblur="set_val(this,0)" value="<?php _e('Secret code','ask-question'); ?>"></div>
<? if (!isset($_GET['fb_xd_fragment'])):?>
<div><img src="/wp-content/themes/invent/lib/capcha/index.php?<?php echo time();?>" id="scode"></div>
<? endif;?>
<div class="but"><button id="button_add" name="button_add" onclick="add_user_order(D.registration)"> <?php _e('Send','zapis');?> </button></div>
<div class="clear"></div>
</form>
</div>
<br />
<div style="font-size:12px" class="hint-coment" align="center"><?php _e('Private-Data-Protection','zapis')?></div>
</div>
</div>
</div>
</div>
</div>
<!-- -->
<? endif ?>
<div class="clear"></div>
</div>
<!-- END CONTENT -->
</div>
<div class="right col">
<div class="container">
<?php get_sidebar('right'); ?>
</div>
</div>
<div class="clear"></div>
</div> <!--#main-->
<?endif;?>
<script language="JavaScript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/selects.js?2"></script>
<script language="JavaScript" type="text/javascript">
<!--
function set_val(o,type){
if (type==1){
if(o.value==o.defaultValue) o.value="";
o.style.color="black";
} else {
if(o.value=="") o.value=o.defaultValue;
}
}
function check_val(event,value) {
var code = event.charCode?event.charCode:event.keyCode;
var c = (code==45 || code==8 || code==9 || ((code >= 48) && (code <= 57)));
if (!c) {
if (window.event) event.returnValue = false;
else event.preventDefault();
}
}
function add_user_order(f){
if (f.student_name.value=="" || f.student_sname.value=="" || f.email.value=="") {
alert("<?php _e('Fill in the Form!','zapis')?>");
return false;
}
D.getElementById("button_add").disabled = true;
makePOSTRequest(f,0,"result_info","rewrite");
}
var PAROPT = new Array();
var WORD = new Array();
WORD[1]='<?php _e('Town:','zapis');?><span class="red">*</span>';
var SELOPT = new Array();
SELOPT[0] = Array();
<? if ($user_country->id):?>
PAROPT[<? echo $user_country->id ?>]=1;
<? endif; ?>
//PAROPT[76]=1;
<?php
$k = $tmp = 0;
foreach ($obj as $r) {
if ($r->p_id!=$tmp) $k = 0;
echo 'SELOPT['.$r->p_id.']['.($k++).'] ="'.$r->id.'|'.$r->name.'"; SELOPT['.$r->id.'] = Array(); ';
$tmp = $r->p_id;
}
?>
window.setTimeout( "load_selects(0, 0 ,1 )", 50 );
-->
</script>
<?php get_footer($footer_template); ?>