<?php
session_start();
include("connection.php");
if(isset($_SESSION['uname']))
{
header("location:account.php");
die();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Catch-22</title>
<link rel="stylesheet" href="style.css" />
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
<script type="text/javascript">
function validateForm()
{
var u=document.forms["registration"]["username"].value;
var p=document.forms["registration"]["password"].value;
var p2=document.forms["registration"]["password2"].value;
var e=document.forms["registration"]["email"].value;
var c=document.forms["registration"]["college"].value;
var f=document.forms["registration"]["phone"].value;
if (u==null || u=="")
{
alert("Enter a Username");
return false;
}
if (p==null || p=="")
{
alert("Enter a Password");
return false;
}
if (p2==null || p2=="")
{
alert("Enter Password again");
return false;
}
if(p!=p2)
{
alert("Password do not match");
return false;
}
if (e==null || e=="")
{
alert("Enter a Email");
return false;
}
var atpos=e.indexOf("@");
var dotpos=e.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=e.length)
{
alert("Not a valid e-mail address");
return false;
}
if (c==null || c=="")
{
alert("Enter a College Name");
return false;
}
if (f==null || f=="")
{
alert("Enter a Phone");
return false;
}
if(!isInteger(f))
{
return false;
}
if(f.length<10)
{
alert("Phone number should have 10 digits");
return false;
}
return true;
}
function isInteger(s)
{
var i;
s = s.toString();
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (isNaN(c))
{
alert("Phone number should be integer");
return false;
}
}
return true;
}
</script>
</head>
<body>
<div id="header">
<div id="catch-b">
<div class="container">
<div id="catch-l">
<div class="nav">
<ul>
<li><a href="faq.php">FAQ</a></li>
<li class="star"></li>
<li><a href="register.php">REGISTER</a></li>
<li class="star"></li>
</ul>
</div>
<div id="reg">LOGIN</div>
</div>
<a id="catch" href="index.php"></a>
<div id="catch-r">
<div class="nav">
<ul>
<li class="star"></li>
<li><a href="login.php">LOGIN</a></li>
<li class="star"></li>
<li><a href="contact.php">CONTACT</a></li>
</ul>
</div>
<div id="scr">TOP SCORES</div>
</div>
</div>
</div>
</div>
<div class="container">
<div id="register">
<div class="content" id="reg-form">
<form name="registration" method="post" action="reg.php" onSubmit="return validateForm()" >
<table>
<tr><td>Username</td><td>:</td><td colspan="2" class="form-input"><input type="text" name="username" /></td></tr><tr><td></td></tr>
<tr><td>Password</td><td>:</td><td colspan="2" class="form-input"><input type="password" name="password"/></td></tr><tr><td></td></tr>
<tr><td>Retype</td><td>:</td><td colspan="2" class="form-input"><input type="password" name="password2" /></td></tr><tr><td></td></tr>
<tr><td>Email</td><td>:</td><td colspan="2" class="form-input"><input type="text" name="email"/></td></tr><tr><td></td></tr>
<tr><td>College</td><td>:</td><td colspan="2" class="form-input"><input type="text" name="college" /></td></tr><tr><td></td></tr>
<tr><td>Mobile</td><td>:</td><td colspan="2" class="form-input"><input type="text" name="phone" /></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr><td colspan="2"> </td><td colspan="2"><input name="submit" class="new-button gradient" type="submit" value="REGISTER" /></td></tr>
</table>
</form>
</div>
<div class="shadow"></div>
</div>
<div id="scores-wrap">
<div id="scores">
<table width="100%">
<tr><th align="left">Username</th><th align="right">Points</th></tr>
<tr><td>Tharun</td><td align="right">09</td></tr>
<tr><td>Jilson</td><td align="right">09</td></tr>
<tr><td>Jismon</td><td align="right">08</td></tr>
<tr><td>Binish</td><td align="right">07</td></tr>
<tr><td>Tobin</td><td align="right">06</td></tr>
<tr><td>Anoop</td><td align="right">05</td></tr>
</table>
</div>
<div id="shadow2"></div>
</div>
</div>
</body>
</html>
修改 谢谢,我解决了问题。
答案 0 :(得分:1)
检查新页面中的以下声明。 name属性的值与原始值不同。在原来它是“用户名”,但在新的它是“名称”。
<tr><td>Name</td><td>:</td><td colspan="2" class="form-input"><input type="text"
name="name" /></td></tr><tr><td></td></tr>