-4

ねえ、ここでもう一度試してみます。コード全体を投稿して、使用できるヘルプが得られるかどうかを確認します。したがって、このように分割された 3 段階のページがあります。メイン コードは、/root/ フォルダーにある registration.php ページに移動することになっています。

registration.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...'>&nbsp;&nbsp;&nbsp;&nbsp;Submit&nbsp;&nbsp;&nbsp;&nbsp;</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...'>&nbsp;&nbsp;<a href='login.php'>Log in</a>&nbsp;&nbsp;</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 ページにリンクしています。メールフォームがメインの登録ページに戻ってくるのに問題があります。メール コードの設定が間違っている可能性があるため、18 行目に問題があることを示す 500 エラーが表示されます。

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();
?>

私の質問は、このメールフォームを正しく修正するためにコード全体を投稿できますか? このメールフォームからメールが送信されないのはなぜですか?

4

2 に答える 2