我构建了自己的联系表单(没有插件),希望有一种安全的方式从我的选项页面获取电子邮件地址。get\\u选项和其他内置WP内容在我的流程中不起作用。php文件。
我试图对WP数据库进行如下查询:
$query = "SELECT * FROM wp_options WHERE option_name = \'nothing_settings_contact\' LIMIT 1";
$sender = mysql_query($query) or die(mysql_error());
但这也行不通。(如果可以的话,我只会得到一个IP,我不知道该怎么办)
那么:如何在不向用户公开的情况下将此电子邮件地址放在那里?
编辑:这是我的流程。php。我试图要求wp博客标题,但它打断了进程。php。
<?php if( isset($_POST) ){
require(\'http://www.bastards-design.de/sebastian/wp-blog-header.php\');
//form validation vars
$formok = true;
$errors = array();
//sumbission data
$ipaddress = $_SERVER[\'REMOTE_ADDR\'];
$date = date(\'d.m.Y\');
$time = date(\'H:i\');
//form data
$name = $_POST[\'name\'];
$email = $_POST[\'email\'];
$website = $_POST[\'website\'];
$enquiry = $_POST[\'enquiry\'];
$message = $_POST[\'message\'];
$receiver = $_POST[\'receiver\'];
$sender = "Niemand";// get_option(\'admin_email\');
if(empty($name)){
$formok = false;
$errors[] = "Sie haben keinen Namen angegeben.";
}
if(empty($email)){
$formok = false;
$errors[] = "Sie haben keine Emailadresse angegeben.";
//validate email address
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$formok = false;
$errors[] = "Sie haben keine gültige Emailadresse angegeben.";
}
if(empty($message)){
$formok = false;
$errors[] = "Das Nachrichtenfeld ist leer.";
}
elseif(strlen($message) < 20){
$formok = false;
$errors[] = "Ihre Nachricht muss mindestens 20 Zeichen enthalten.";
}
if($formok){
$headers = "From: {$email}" . "\\r\\n";
$headers .= \'Content-type: text/html; charset=UTF-8\' . "\\r\\n";
$emailbody = "<p><strong>Name: </strong> {$name} </p>
<p><strong>Website: </strong> {$website} </p>
<p><strong>Nachricht: </strong> {$message} </p>
<p>Diese Nachricht wurde am {$date} um {$time} über {$sender} gesendet.</p>";
if($receiver){
mail($receiver,"Anfrage ".$name,$emailbody,$headers);
}
else{
mail(\'Sebastian.Starke1@googlemail.com\',"Error",$emailbody,$headers);
}
}
//what we need to return back to our form
$returndata = array(
\'posted_form_data\' => array(
\'name\' => $name,
\'email\' => $email,
\'website\' => $website,
\'enquiry\' => $enquiry,
\'message\' => $message
),
\'form_ok\' => $formok,
\'errors\' => $errors
);
//if this is not an ajax request
if(empty($_SERVER[\'HTTP_X_REQUESTED_WITH\']) && strtolower($_SERVER[\'HTTP_X_REQUESTED_WITH\']) !== \'xmlhttprequest\'){
//set session variables
session_start();
$_SESSION[\'cf_returndata\'] = $returndata;
//redirect back to form
header(\'location: \' . $_SERVER[\'HTTP_REFERER\']);
}
}