我想通過使用xampp在php中製作註冊頁面,但我遇到了問題。當我運行我的PHP文件,它提供了以下錯誤:php註冊系統錯誤
Notice: Undefined index: UserName in C:\xampp\htdocs\register.php on line 3
Notice: Undefined index: UserSurname in C:\xampp\htdocs\register.php on line 4
Notice: Undefined index: UserMail in C:\xampp\htdocs\register.php on line 5
Notice: Undefined index: UserPassword in C:\xampp\htdocs\register.php on line 6
Notice: Undefined index: UserTel in C:\xampp\htdocs\register.php on line 7
Warning: require(class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\register.php on line 24
Fatal error: require() [function.require]: Failed opening required 'class.phpmailer.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\register.php on line 24
我的PHP文件,register.php:
<?php
$username=$_POST['UserName'];
$usersurname=$_POST['UserSurname'];
$usermail=$_POST['UserMail'];
$userpass=$_POST['UserPassword'];
$usertelephone=$_POST['UserTel'];
$con = mysql_connect("localhost","root","rockenpeace");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbe", $con);
mysql_query("INSERT INTO user (UserName,UserSurname,UserMail, UserPassword, UserTel)
VALUES('$username','$usersurname','$usermail','$userpass','$usertelephone')");
mysql_close($con);
try
{
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->CharSet="utf-8";
$mail->Username = "[email protected]";
$mail->Password = "password";
$mail->From = "[email protected]";
$mail->FromName="DBE Yazılım";
$mail->AddAddress($_POST['usermail']);
$mail->Subject = "Registration Information";
$mail->Body = "Hello your password is " . $userpass;
//$mail->AddAttachment($path);
$mail->Send();
echo 'Message has been sent.';
}
catch(Exception $e)
{
echo 'hata'.$e->getMessage();
}
header("location:confirmation.php"); ?>
,並在我的html頁面:
<input type="text" name="UserMail" id="UserMail" size="30" />
<input type="text" name="UserName" id="UserName" size="30" />
<input type="text" name="UserSurname" id="UserSurname" size="30" />
<input type="text" name="UserTel" id="UserTel" size="30" />
<input type="password" name="UserPassword" id="UserPassword" size="30" />
當我在php中運行print_r($ _ POST)時,它寫入Array()。對不起,我是php.so的初學者,如果我犯了錯誤,警告我。 – rockenpeace 2012-07-17 11:28:53
你剛剛給出了你的smtp信息。我爲你編輯它。 – Martin 2012-07-17 11:29:46
如果它正在寫入Array(),則表單數據沒有傳遞給它。你也應該向我們展示你的標記。 – Martin 2012-07-17 11:31:20