⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alt_new.php

📁 A website for keeping track of wishes for your character in WoW Users are able to make a user accoun
💻 PHP
字号:
<?php
include "auth.inc.php";
include "conn.inc.php";
?>

<html>
	<head>
		<title>WoW-Wish: Make an alt</title>
		<link rel="stylesheet" href="wish.css">
	</head>
	<body>
		<?php include "header.inc.php"; ?>
        <h1>Make an alt</h1>
<?php
if (isset($_POST['submit']) && $_POST['submit'] == "Create") //from a submit
{
	if ($_POST['altname'] != "" && $_POST['altrealm'] != "") //fields are filled
	{
        //check if name/realm combo is unique
        $s_altname = addslashes($_POST['altname']);
        $s_altrealm = addslashes($_POST['altrealm']);
        $query = "SELECT * FROM alts WHERE altname = '". $s_altname ."' AND altrealm = '". $s_altrealm ."'"; //sanitise
        $result = mysql_query($query) 
        or die(mysql_error());

        if (mysql_num_rows($result) != 0)
        {	//combo isn't unique = :(
            echo "<p><h2>That character already exists</h2> choose another name/realm combo that hasn't been taken</p>";
            include "alt_new.form.inc.php"; 
        }
        elseif (preg_match("/^\w{3,12}$/",$_POST['altname'])==0 || preg_match("/^[\D]{3,12}$/",$_POST['altname'])==0)
        {
            // "/^\w{3,12}$/"  -->  only letters/numbers=1, any special non-letter character =0
            // "/^[\D]{3,12}$/"  --> only letters = 1, any number = 0
            echo "<p><h2>Invalid character name</h2> You can only use letter characters, and needs to be 3-13 letters long</p>";
            include "alt_new.form.inc.php"; 
        }
        elseif(($_POST['faction'] != 1) && ($_POST['faction'] != 2))
        {
            //didn't select horde or alliance
            //echo $_POST['faction'];
            echo "<p><h2>Pick a side</h2> You need to choose if your character is horde or alliance</p>";
            include "alt_new.form.inc.php"; 
        }
        else
        {   //combo is unique = :)
            //insert into db

            $s_altname = ucfirst(strtolower(addslashes($_POST['altname'])));
            $s_altrealm = addslashes($_POST['altrealm']);
            $s_session_user_logged = addslashes($_SESSION['user_logged']);
            $s_faction = addslashes($_POST['faction']);
            $query = "INSERT INTO alts (altname, altrealm, owner, faction) " .
                    "VALUES ('" . $s_altname . "', " ."'" . $s_altrealm ."','".
                    $s_session_user_logged ."','".$s_faction."');";
            $result = mysql_query($query) or die(mysql_error());
			
            $s_altname = htmlentities($s_altname);
            echo "<p><h2>" .$s_altname. " has been registered as one of your characters<br /></h2>".
                "You can go to the <a href=\"index.php\">home page</a>, ".
                "go to the <a href=\"alt_list.php\">listing of your characters</a> or go and make another alt</p>";
			include "alt_new.form.inc.php"; 
            die();
        }
	}
	else
	{
        echo "<h2>You need to fill in the alt name</h2>";
		include "alt_new.form.inc.php"; 
	}
}
else
{
    //fresh start
	include "alt_new.form.inc.php";
}
?>
    </body>
</html>

<?php
        /*
        TODO split this into two parts
        1-name/realm
        2-armory lookup
        2a lookup success: ask user to validate
        2b lookup failure or user doesn't think it's right: manual input
        */
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -