嘿,所以我在这里再试一次,我将尝试发布整个代码,看看是否可以获得一些我可以使用的帮助。所以我有一个像这样分解的 3 阶段页面,主要代码假设位于 /root/ 文件夹中的 registration.php 页面上。
注册.php (位置:/root/)
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
//Prevent the user visiting the logged in page if he/she is already logged in
if(isUserLoggedIn()) { header("Location: account.php"); die(); }
//Forms posted
if(!empty($_POST))
{
$errors = array();
$email = trim($_POST["email"]);
$username = trim($_POST["username"]);
$displayname = trim($_POST["displayname"]);
$password = trim($_POST["password"]);
$confirm_pass = trim($_POST["passwordc"]);
$captcha = md5($_POST["captcha"]);
if ($captcha != $_SESSION['captcha'])
{
$errors[] = lang("CAPTCHA_FAIL");
}
if(minMaxRange(5,25,$username))
{
$errors[] = lang("ACCOUNT_USER_CHAR_LIMIT",array(5,25));
}
if(minMaxRange(5,25,$displayname))
{
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT",array(5,25));
}
if(!ctype_alnum($displayname)){
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
}
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$confirm_pass))
{
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50));
}
else if($password != $confirm_pass)
{
$errors[] = lang("ACCOUNT_PASS_MISMATCH");
}
if(!isValidEmail($email))
{
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
//End data validation
if(count($errors) == 0)
{
//Construct a user object
$user = new User($username,$displayname,$password,$email);
//Checking this flag tells us whether there were any errors such as possible data duplication occured
if(!$user->status)
{
if($user->username_taken) $errors[] = lang("ACCOUNT_USERNAME_IN_USE",array($username));
if($user->displayname_taken) $errors[] = lang("ACCOUNT_DISPLAYNAME_IN_USE",array($displayname));
if($user->email_taken) $errors[] = lang("ACCOUNT_EMAIL_IN_USE",array($email));
}
else
{
//Attempt to add the user to the database, carry out finishing tasks like emailing the user (if required)
if(!$user->userCakeAddUser())
{
if($user->mail_failure) $errors[] = lang("MAIL_ERROR");
if($user->sql_failure) $errors[] = lang("SQL_ERROR");
}
}
}
if(count($errors) == 0) {
$successes[] = $user->success;
}
}
require_once("$template/head.php");
//Links Guide Web Design1
putenv('DORUMENT_ROOT=');
$docroot='';
putenv('DORUMENT_ROOT=');
$dir_home_web_design1='../';
putenv('DORUMENT_ROOT=');
$class_home_web_design1='';
putenv('DORUMENT_ROOT=');
$dir_login_web_design1='';
putenv('DORUMENT_ROOT=');
$class_login_web_design1='current';
//Links Guide Web Design1
echo "
<body >
<!-- header -->
<div>";
include "$template/header.php";
echo "
</div>
<!-- header -->
<!-- register -->
<div>";
include "$template/register.php";
echo "
</div>
<!-- register -->
<!-- footer -->
<div>";
include "$template/footer.php";
echo "
</div>
<!-- footer -->
<!-- Javascript - jQuery -->
<script src='http://code.jquery.com/jquery.min.js'></script>
<script>window.jQuery || document.write('<script src='js/jquery-1.7.2.min.js'> <\/script>')</script>
</body>
</html>";
?>
该链接指向位于 /roots/models/template/chooser/ 的另一个注册页面,该页面具有电子邮件表单:
注册 (位置:/roots/models/template/chooser/)
<?php
echo "
<!-- register -->
<div class='whiteattire'
<div id='regbox'>
<div id='wrap'>
<div class='container3'>
<div class='row'>
<div class='span3 hidden-phone'></div>
<div class='span6' id='form-login'>
<form name='htmlform' action='$template/email.php' method='post' class='form-horizontal well' >
<fieldset>
<legend>Register for an account</legend>";
echo resultBlock($errors,$successes);
echo "
<br>
<div class='control-group'>
<div class='control-label'>
<label>Name</label>
</div>
<div class='controls'>
<input type='text' placeholder='Type name' name='name' class='input-large'>
</div>
</div>
<div class='control-group'>
<div class='control-label'>
<label>E-mail</label>
</div>
<div class='controls'>
<input type='text' placeholder='Type e-mail' name='email' class='input-large'>
</div>
</div>
<div class='control-group'>
<div class='control-label'>
<label>Telephone</label>
</div>
<div class='controls'>
<input type='text' placeholder='Type telephone' name='telephone' class='input-large'>
</div>
</div>
<div class='control-group'>
<div class='control-label'>
<label>Password</label>
</div>
<div class='controls'>
<input type='text' placeholder='Type password' name='password' class='input-large'>
</div>
</div>
<div class='control-group'>
<div class='control-label'>
<label>Security Code:</label>
</div>
<div class='controls'>
<img src='models/captcha.php'>
</div>
</div>
<div class='control-group'>
<div class='control-label'>
<label>Enter Security Code:</label>
</div>
<div class='controls'>
<input type='text' placeholder='Type code' name=captcha' class='input-large'>
</div>
</div>
<div class='control-group'>
<div class='controls'>
<button type='submit' id='submit' class='btn btn-primary button-loading' data-loading-text='Loading...'> Submit </button>
<br></br>
<button type='button' class='btn btn-secondary button-loading' data-loading-text='Loading...'><a href='forgot-password.php'>Forgot Password</a></button>
<button type='button' class='btn btn-secondary button-loading' data-loading-text='Loading...'> <a href='login.php'>Log in</a> </button>
</div>
</div>
</fieldset>
</form>
</div>
<div class='span3 hidden-phone'></div>
</div>
</div>
<div id='push'></div>
</div>
</div>
</div>
<!-- register -->
<!-- register -->
<!-- register -->
";
?>
该链接到另一个 email.php 页面,该页面假定创建电子邮件并发送它。我在回复主注册页面的电子邮件表单时遇到问题。我想我可能错误地设置了电子邮件代码,这就是为什么我收到 500 错误,说第 18 行有问题。这是电子邮件代码,希望你们能提供帮助:
email.php (位置:/roots/models/template/chooser/)
<?php
if(isset($_POST['email'])) {
// CHANGE THE TWO LINES BELOW
$email_to = "danielobo2@yahoo.com";
$email_subject = "Registering to blanky-store.net web design account.";
//Forms posted
if(!empty($_POST))
{
$errors = array();
$email = trim($_POST["email"]);
$name = trim($_POST["name"]);
$telephone = trim($_POST["telephone"]);
$password = trim($_POST["password"]);
$captcha = md5($_POST["captcha"]);
if ($captcha != $_SESSION['captcha'])
$errors[] = lang("CAPTCHA_FAIL");
if(minMaxRange($name))
$errors[] = lang("CONFIG_NAME_CHAR_LIMIT");
if(!ctype_alnum($name))
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
if(!isValidEmail($telephone))
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT");
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$confirm_pass))
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50));
if(!isValidEmail($email))
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
//End data validation
if(strlen($error_message) > 0) {
echo($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string( $mystring )
{
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$mystring);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Password: ".clean_string($password)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
if (mail($email_to, $email_subject, $email_message, $headers))
header("Location: http://blanky-store.net/index.php");
}
}
die();
?>
我的问题是可以发布整个代码以正确修复此电子邮件表单吗?为什么此电子邮件表单不发送电子邮件?