ここに「チェック」があり、何かが起こった場合、それはecho
フレーズのようなThe username you supplied is already in use
ものになります。ただし、表示する場合は、そのテキストを含む空白のページにのみ表示されます。ここで何が問題なのですか?
PHP
<?php
include('./dbconnect/global.php');
if ($_POST['register']) {
$username = mysql_real_escape_string(strip_tags($_POST['username']));
$password = mysql_real_escape_string(strip_tags($_POST['password']));
$email = mysql_real_escape_string(strip_tags($_POST['email']));
if (!$username||!$password||!$email)
echo "PLease Fill in The Required Fields";
else {
//check if username is taken
$check = mysql_query("SELECT * FROM users WHERE username='$username'");
if (mysql_num_rows($check) >= 1)
echo "The Username you Supplied Is Already in Use! <a href='./register'>Back</a>";
$check2 = mysql_query("SELECT * FROM users WHERE email='$email'");
if (mysql_num_rows($check) >= 1)
echo "The Email you Supplied Is Already in Use! <a href='./register'>Back</a>";
else {
$password2 = md5($password);
$register = mysql_query("value and stuff)") or die(mysql_error());
echo "Thanks for registering, $username! <a href='./index'>Home</a>";
}
}
}
else {
?>
HTML
<html>
<head>
<title>CoreCrafters</title>
<link rel="stylesheet" type="text/css" href="./css/main.css">
</head>
<body>
<?php include('./include/nbar.php') ?>
<div id="main">
<div id="register">
<div id="wrapper">
<form action="register" method="POST">
Username
<br />
<input type="username" name="username">
<br />
Password
<br />
<input type="password" name="password">
<br />
Email
<br />
<input type="email" name="email">
<br /><br />
<input type="submit" name="register" value="Register">
</form>
</div>
</div>
</div>
<?php include('./include/footer.php') ?>
</body>
</html>
PHP の終了 (最後に ELSE から)
<?php
}
?>
CSS
body {
margin: 0;
padding: 0;
background-color: #EEE;
}
#headerbar {
width: 100%;
background-color: #000;
}
a {
color: #069;
font-weight: bold;
text-decoration: none;
transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
}
a:hover {
color: #c00;
}
#nav {
padding: 0;
width: 100%;
float: left;
list-style: none;
margin: 0 0 3em 0;
background-color: #f2f2f2;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
#nav li {
float: left;
}
#nav li a {
color: #069;
display: block;
font-weight: bold;
padding: 8px 15px;
text-decoration: none;
transition: all 0.2s linear;
border-right: 1px solid #ccc;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
}
#nav li a:hover {
color: #c00;
background-color: #fff;
}
#footer {
width: 94%;
padding: 10px;
margin-top: 10px;
margin-left: auto;
padding-left: 0px;
text-align: center;
margin-right: auto;
padding-right: 0px;
border: 1px solid #DDD;
background-color: #FFF;
}
#main {
width: 94%;
margin-top: 50px;
min-height: 500px;
margin-left: auto;
margin-right: auto;
border: 1px solid #DDD;
background-color: #FFF;
}
#register {
width: 15%;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
text-align: center;
background-color: #CCC;
border: 1px solid #AAA;
}
#logbar {
width: 150px;
float: right;
min-height: 36px;
padding-left: 5px;
padding-right: 50px;
background-color: #DDD;
}
リクエストに応じて、ほとんどのページをここに投稿しました。