PHP用户注册和登录系统

时间:2016-09-11 10:47:42

标签: php

我是PHP的初学者,我想知道如何创建用户注册和登录系统。在线查看了一些教程,并下载了源代码,但是当用户注册时,它只显示“用户成功注册!”在注册页面上,不会将用户重定向到用户/登录页面。有没有人知道哪个教程显示/教授这种东西?如果是的话,请给我一个链接,如果有人愿意以任何其他方式帮助我,请善意。

这是我的 dbconroller.php 代码:

<div class="name">
							Rob Kardashian
						</div>
					</div>
				</a>
			</div>
					<div class="channelListEntry">
				<a href="/zayn_malik">
					<div class="image">
						<img src="http://cdn.posh24.com/images/:profile/014cf47ca44daf8f44a3e0720929ee327" alt="Zayn Malik"/>
					</div>
					
					 
										<div class="info">
						<div class="status-container">
							<div class="position">4</div>
							 
								<div class="img pos"></div>
								<div class="value">+12</div>
													
						</div>
						<div class="name">
							Zayn Malik
						</div>
					</div>
				</a>
			</div>
					<div class="channelListEntry">
				<a href="/kanye_west">
					<div class="image">
						<img src="http://cdn.posh24.com/images/:profile/03f352f71ffab135cd81821eb190d4832" alt="Kanye West"/>
					</div>
					
					 
										<div class="info">
						<div class="status-container">
							<div class="position">5</div>
							 
								<div class="img pos"></div>
								<div class="value">+16</div>
													
						</div>
						<div class="name">
							Kanye West
						</div>
					</div>
				</a>
			</div>
					<div class="channelListEntry">
				<a href="/kendall_jenner">
					<div class="image">
						<img src="http://cdn.posh24.com/images/:profile/066d5c02547c4357f1bc5f633c68f4085" alt="Kendall Jenner"/>
					</div>

这是我的 registered_users.sql 代码:

<?php
class DBController {
    private $host = "localhost";
    private $user = "root";
    private $password = "";
    private $database = "registered_users";

    function __construct() {
        $conn = $this->connectDB();
        if(!empty($conn)) {
            $this->selectDB($conn);
        }
    }

    function connectDB() {
        $conn = mysql_connect($this->host,$this->user,$this->password);
        return $conn;
    }

    function selectDB($conn) {
        mysql_select_db($this->database,$conn);
    }

    function runQuery($query) {
        $result = mysql_query($query);
        while($row=mysql_fetch_assoc($result)) {
            $resultset[] = $row;
        }       
        if(!empty($resultset))
            return $resultset;
    }

    function numRows($query) {
        $result  = mysql_query($query);
        $rowcount = mysql_num_rows($result);
        return $rowcount;   
    }

    function updateQuery($query) {
        $result = mysql_query($query);
        if (!$result) {
            die('Invalid query: ' . mysql_error());
        } else {
            return $result;
        }
    }

    function insertQuery($query) {
        $result = mysql_query($query);
        if (!$result) {
            die('Invalid query: ' . mysql_error());
        } else {
            return $result;
        }
    }

    function deleteQuery($query) {
        $result = mysql_query($query);
        if (!$result) {
            die('Invalid query: ' . mysql_error());
        } else {
            return $result;
        }
    }
}
?>

我的 index.php 是:

-- phpMyAdmin SQL Dump
-- version 4.0.4.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 22, 2014 at 12:48 PM
-- Server version: 5.5.32
-- PHP Version: 5.4.19

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `phppot_examples`
--

-- --------------------------------------------------------

--
-- Table structure for table `registered_users`
--

CREATE TABLE IF NOT EXISTS `registered_users` (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(255) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `password` varchar(25) NOT NULL,
  `email` varchar(55) NOT NULL,
  `gender` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 个答案:

没有答案