[英]I need some assistance in making an email activation with php oop syntax
我几乎可以使用我的代码,但是更喜欢使用我的用户类,但是当在我的registration.php文件中实现$ user = new User()时,它将无法工作。 到目前为止,我已经获得了以下代码。 这只是代码的一部分。
<?php
require_once 'core/init.php'; // we have autoloader here
if(isset($_POST['submit'])) {
$random = rand();
$name = $_POST['name'];
$email = $_POST['email'];
$to = 'piano0011@hotmail.com';
$header = 'From: piano0011@hotmail.com';
$subject = 'Email activation is required';
$message = <<<EMAIL
Hello $name How are you? Thank you for registering and please
click on the link to activate your account:
.http://localhost/pianocourse101/activate.php?
email=$_POST['email']
EMAIL;
mail($to, $subject, $message, $header);
}
我希望这些代码足够多,但很乐意提供更多代码...
包含激活链接http://时,我也遇到以下错误
解析错误:语法错误,意外的''(T_ENCAPSED_AND_WHITESPACE),期望标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)在C:\\ xampp \\ htdocs \\ pianocourse101 \\ register.php中的第17行
但是,我希望做类似$ user-> data()-> username的操作
但我不确定该怎么做。 我设法在profile.php中做到了这一点,但是由于某种原因,当我在这里尝试时,它说明了一些非对象错误。.我不确定非对象是什么意思,但是我包括了$ user = new User() ; 这应该工作的行...我是php的新手,并希望通过简单的逐步说明
if($validation->passed()) {
$user = new User();
$salt = Hash::salt(32);
try {
$user->create(array(
'username' => Input::get('username'),
'password' => Hash::make(Input::get('password'), $salt),
'salt' => $salt,
'name' => Input::get('name'),
'joined' => date('Y-m-d H:i:s'),
'group' => 0,
'email' => Input::get('email'),
'activated' => 0,
'country' => Input::get('country'),
'token' => Input::get('token'),
'email_code' => Hash::make(Input::get('username', microtime()))
));
Session::flash('home', 'You have been registered and can now log in!');
// Redirect::to('index.html');
} catch(Exception $e) {
die($e->getMessage());
}
} else {
foreach($validation->errors() as $error) {
echo $error, '<br>';
}
}
<form action="" method="post" id="simpleform">
<div class ="field">
<label for="username">Username</label>
<input type="text" name="username" id="username" value="<?php echo
escape(Input::get('username')); ?>" autocomplete="off">
</div>
您的Heredoc格式不好。 close元素不能缩进:
$message = <<<EMAIL
Hello $name How are you? Thank you for registering and please
click on the link to activate your account:
.http://localhost/pianocourse101/activate.php?
email=$_POST['email']
EMAIL; // on the first column
从文档 :
请务必注意,带有结束标识符的行除分号(;)外,不得包含其他任何字符。 特别是这意味着标识符不能缩进 ,分号之前或之后可能没有空格或制表符。 同样重要的是要认识到,结束标识符之前的第一个字符必须是本地操作系统定义的换行符。 在包括Mac OS X在内的UNIX系统上,这是\\ n。结束定界符也必须后跟换行符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.