【发布时间】:2011-04-02 08:43:09
【问题描述】:
我使用以下代码在我的网站上注册用户。问题是当用户注册时 apache 没有响应并崩溃。
我的代码有中断还是我做错了什么????
<?php
include ('../includes/db_connect.php');
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
unset($username);
//include 'register.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (firstname, email, username, password)
VALUES('$firstname', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
// mail user their information
//$yoursite = ‘www.blahblah.com’;
//$webmaster = ‘yourname’;
//$youremail = ‘youremail’;
//
//$subject = "You have successfully registered at $yoursite...";
//$message = "Dear $firstname, you are now registered at our web site.
// To login, simply go to our web page and enter in the following details in the login form:
// Username: $username
// Password: $password
//
// Please print this information out and store it for future reference.
//
// Thanks,
// $webmaster";
//
//mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
//
//echo "Your information has been mailed to your email address.";
?>
【问题讨论】:
-
Apache 的
error.log中的任何内容?崩溃究竟是什么样的? -
顺便说一下,您的脚本极易受到 SQL 注入的攻击。参见例如stackoverflow.com/questions/60174/… 或 stackoverflow.com/questions/47087/…
-
启动 Apache2.2 服务 Apache2.2 服务正在运行。 rmine 服务器的完全限定域名,使用 192.168.1.106 作为 ServerName [Mon Dec 01 11:00:22 2008] [notice] Apache/2.2.10 (Win32) 已配置 -- 恢复正常操作 [Mon Dec 01 11:00: 22 2008] [notice] 服务器构建:2008 年 10 月 10 日 12:39:04 [Mon Dec 01 11:00:22 2008] [notice] Parent:创建子进程 1844 httpd.exe:无法可靠地确定服务器的完全限定域名称,使用 192.168.1.106 作为 ServerName
标签: php apache post registration