我尝试使用邮件功能发送简单的电子邮件并且它有效。但是当我尝试将它插入我的程序时它不会。谁能告诉我哪一部分是错的,因为我很确定这不是关于 xampp/sendmail 配置的——我已经尝试了 2 个简单的邮件程序,除了这个之外它们都可以工作。
我尽力把(...) 代替不必要的行。我认为问题在于,它无法进入 prog 读取电子邮件功能部分的部分?
这是我的 register.php:
<?
session_start();
if(isset($_POST['register']))
{
include('/class.register.php');
$register = new Register();
if($register->process()) {
header('location: login.php');
}
else {
$register->show_errors();
}
}
?>
<form method= "POST" action="<?=$_SERVER['PHP_SELF'];?>">
<table>
<tr><td>Username:</td><td><input type="text" name="ruser" required="required" /></td></tr>
<tr><td>Email:</td><td><input type="text" name="remail" required="required" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="rpass" required="required" /></td></tr>
<tr><td>Title:</td><td><input type="text" name="rtitle" required="required" /></td></tr>
<tr><td>First Name:</td><td><input type="text" name="rfname" required="required" /></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="rlname" required="required" /></td></tr>
<tr><td>Mobile Number:</td><td><input type="text" name="rmobile" required="required" /></td></tr>
</table>
<input type="submit" name="register" value="Sign Up" />
</form>
这是我的 class.register.php:
<?
class Register
{
...
private $errors;
public function __construct()
{
$this->errors = array();
...;
$this->token = $_POST['token'];
$this->passmd5 = md5($this->password);
}
public function process()
{
if($this->valid_data() && $this->send_email())
$this->register();
return count($this->errors)? 0: 1;
}
public function filter($var)
{
return preg_replace('/[^a-zA-z0-9@.]/','',$var);
}
public function user_exists()
{
...
}
public function email_exists()
...
public function register()
{
...
}
public function show_errors()
echo "<h3>Errors</h3>";
foreach($this->errors as $key=>$value)
echo $value."<br>";
public function valid_data()
...
public function send_email()
{
$from = 'jeremiah@citydelivery.ph';
$to = $_POST['remail'];
$subject = 'Registration confirmation';
$message = 'Please click the following link or copy and paste it
into your browser to complete the registration process: ';
$message .= 'http://example.com/confirm.php?u=';
$message .= urlencode($_POST['ruser']);
$message .= '&t=';
$message .= urlencode($_POST['token']);
return mail($to, $subject, $message, $from);
}
}
?>