PHP求助,求大神帮助用PHP和MYSQL知识编写一道基础题。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP求助,求大神帮助用PHP和MYSQL知识编写一道基础题。相关的知识,希望对你有一定的参考价值。
用php+MYAQL写用户注册和登录功能,必须还要有用户信息查看,用户信息修改,以及修改密码,这5项功能,可以自行添加更多属性和功能。
求大神帮助,将作品打包发到602882638@qq.com,或者百度里面(百度我不太会用。。。)
谢谢您了。
class OneFileLoginApplication
private $db_type = "sqlite";
private $db_sqlite_path = "./users.db";
private $db_connection = null;
private $user_is_logged_in = false;
public $feedback = "";
public function __construct()
if ($this->performMinimumRequirementsCheck())
$this->runApplication();
private function performMinimumRequirementsCheck()
if (version_compare(PHP_VERSION, '5.3.7', '<'))
echo "Sorry, Simple PHP Login does not run on a PHP version older than 5.3.7 !";
elseif (version_compare(PHP_VERSION, '5.5.0', '<'))
require_once("libraries/password_compatibility_library.php");
return true;
elseif (version_compare(PHP_VERSION, '5.5.0', '>='))
return true;
return false;
public function runApplication()
if (isset($_GET["action"]) && $_GET["action"] == "register")
$this->doRegistration();
$this->showPageRegistration();
else
$this->doStartSession();
$this->performUserLoginAction();
if ($this->getUserLoginStatus())
$this->showPageLoggedIn();
else
$this->showPageLoginForm();
private function createDatabaseConnection()
try
$this->db_connection = new PDO($this->db_type . ':' . $this->db_sqlite_path);
return true;
catch (PDOException $e)
$this->feedback = "PDO database connection problem: " . $e->getMessage();
catch (Exception $e)
$this->feedback = "General problem: " . $e->getMessage();
return false;
private function performUserLoginAction()
if (isset($_GET["action"]) && $_GET["action"] == "logout")
$this->doLogout();
elseif (!empty($_SESSION['user_name']) && ($_SESSION['user_is_logged_in']))
$this->doLoginWithSessionData();
elseif (isset($_POST["login"]))
$this->doLoginWithPostData();
private function doStartSession()
session_start();
private function doLoginWithSessionData()
$this->user_is_logged_in = true;
private function doLoginWithPostData()
if ($this->checkLoginFormDataNotEmpty())
if ($this->createDatabaseConnection())
$this->checkPasswordCorrectnessAndLogin();
private function doLogout()
$_SESSION = array();
session_destroy();
$this->user_is_logged_in = false;
$this->feedback = "You were just logged out.";
private function doRegistration()
if ($this->checkRegistrationData())
if ($this->createDatabaseConnection())
$this->createNewUser();
return false;
private function checkLoginFormDataNotEmpty()
if (!empty($_POST['user_name']) && !empty($_POST['user_password']))
return true;
elseif (empty($_POST['user_name']))
$this->feedback = "Username field was empty.";
elseif (empty($_POST['user_password']))
$this->feedback = "Password field was empty.";
return false;
private function checkPasswordCorrectnessAndLogin()
$sql = 'SELECT user_name, user_email, user_password_hash
FROM users
WHERE user_name = :user_name OR user_email = :user_name
LIMIT 1';
$query = $this->db_connection->prepare($sql);
$query->bindValue(':user_name', $_POST['user_name']);
$query->execute();
$result_row = $query->fetchObject();
if ($result_row)
if (password_verify($_POST['user_password'], $result_row->user_password_hash))
$_SESSION['user_name'] = $result_row->user_name;
$_SESSION['user_email'] = $result_row->user_email;
$_SESSION['user_is_logged_in'] = true;
$this->user_is_logged_in = true;
return true;
else $this->feedback = "Wrong password.";
else $this->feedback = "This user does not exist.";
return false;
private function checkRegistrationData()
if (!isset($_POST["register"]))
return false;
if (!empty($_POST['user_name'])
&& strlen($_POST['user_name']) <= 64
&& strlen($_POST['user_name']) >= 2
&& preg_match('/^[a-z\\d]2,64$/i', $_POST['user_name'])
&& !empty($_POST['user_email'])
&& strlen($_POST['user_email']) <= 64
&& filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)
&& !empty($_POST['user_password_new'])
&& !empty($_POST['user_password_repeat'])
&& ($_POST['user_password_new'] === $_POST['user_password_repeat'])
)
return true;
elseif (empty($_POST['user_name']))
$this->feedback = "Empty Username";
elseif (empty($_POST['user_password_new']) || empty($_POST['user_password_repeat']))
$this->feedback = "Empty Password";
elseif ($_POST['user_password_new'] !== $_POST['user_password_repeat'])
$this->feedback = "Password and password repeat are not the same";
elseif (strlen($_POST['user_password_new']) < 6)
$this->feedback = "Password has a minimum length of 6 characters";
elseif (strlen($_POST['user_name']) > 64 || strlen($_POST['user_name']) < 2)
$this->feedback = "Username cannot be shorter than 2 or longer than 64 characters";
elseif (!preg_match('/^[a-z\\d]2,64$/i', $_POST['user_name']))
$this->feedback = "Username does not fit the name scheme: only a-Z and numbers are allowed, 2 to 64 characters";
elseif (empty($_POST['user_email']))
$this->feedback = "Email cannot be empty";
elseif (strlen($_POST['user_email']) > 64)
$this->feedback = "Email cannot be longer than 64 characters";
elseif (!filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL))
$this->feedback = "Your email address is not in a valid email format";
else
$this->feedback = "An unknown error occurred.";
return false;
//没办法,不允许发这么多字; 参考技术B 建议你看下phplib 参考技术C 看看 PHP100 视频 里面有你想要的 参考技术D 很简单,但是分太少了吧追问
你会做的再给15分 只有这么多了,你被采纳后还会有20分奖励啊
追答是么,好吧。分给我
第5个回答 2014-06-06 建表,提交,查询,对比,返回数据PHP如何实现指纹验证,求大神指导
用户注册时使用指纹录入仪录入指纹,以记录用户信息,也防止用户重复注册。了解了下,都是用其他语言做二次开发实现这个功能的。要使用PHP实现此功能。如何实现?求大神指导!
php貌似无法实现这个,指纹录入仪貌似也没有针对php进行开发的demo。其主要原因是php是解释型语言。一般录入仪都有很多不同语言的demo,可以找个你熟悉的语言编写。可以通过数据库作为桥梁进行和php那边通讯。追问
我看中控的u4000B有个zkonline sdk 可以放在网页上的。这个用PHP可以开发吗?
追答应该是可以的。 主要看demo怎么做的
追问关键是没有PHP的demo。只有asp的。
追答如果只有for asp你需要看一下是否是基于actionx组件实现的.如果这样需要你自己改写转化成php的代码了.或者与提供商索要代码.
如果是纯asp实现的话,那么php就能实现.但是这种情况基本是不可能的.因为asp也是解释型语言.必须借助第三方工具进行桥接.
感谢。
参考技术A 设计思想啥的都是语言无关性吧……追问额,我是编程新手。你这么说,就是用PHP也能够实现咯?
追答应该可以的吧,这种硬件的一般实现方式,都是通过API 或者 webservices来对接硬件实现的~
我之前用PHP做过闸机扫描二维码进入旅游园区就是通过 RPC来对接闸机的程序 实现的~
以上是关于PHP求助,求大神帮助用PHP和MYSQL知识编写一道基础题。的主要内容,如果未能解决你的问题,请参考以下文章
php html求助大神 <a>标签 因为网页卡 出现多次点击 一起提交事件
大神,求请教我想问一下 PHP和 软件逆向开发 这两个选哪个 求给下 详细解释 纠结中