Source

myswap / 1 / code / App / Lib / Action / SignupAction.class.php

<?php
// 本文档自动生成,仅供测试运行
class SignupAction extends Action
{
    public function index()
    {
        $this->display();
    }

    public function _empty()
    {
        $this->display(404);
    }
    public function addUser()
	{    	
		$msg_error="";
		if($_POST["password"]==$_POST["confirm_password"]){
			if(valid_email($_POST["email"])){
				if(valid_username($_POST["username"])){
					$User=M("User");
					$User->create();
					$User->friends=trim($_POST["friends"]);
					$User->username=$_POST["username"];
					$User->password=sha1($_POST["password"]);
					$User->add();
					$this->assign('msg_success',"signed up");
				}else{
					$msg_error.=valid_username($_POST["username"]);
				}
			}else{
				$msg_error.=valid_email($_POST["email"]);
			}
		}else{
			$msg_error.="password did not match";
		}
		if($msg_error){
			$this->assign('msg_error',$msg_error);
			$this->display('index');
		}else{
			header("Location: http://".$_SERVER["HTTP_HOST"]."/".$_POST["username"]."/");
		}
    }

}
?>