我创建了一个使用XAmpp的简单注册php页面,问题是每次按下提交按钮时,它只链接到一个显示“找不到对象”的页面,而不是显示成功的提醒。
我不知道我的代码是否有任何问题,因为没有显示错误,我创建的其他注册页面几乎与此相同,除了这个没有在数据库中添加输入。
非常感谢帮助。
<html>
<?php
session_start();
require 'Connect.php';
$flag=0;
if(empty($_POST['FirstName'])){
$FirstName = '';
$flag=1;
} else
$FirstName = ($_POST['FirstName']);
if(empty($_POST['LastName'])){
$LastName = '';
$flag=1;
} else
$LastName = ($_POST['LastName']);
if(empty($_POST['Gender'])){
$Gender = '';
$flag=1;
} else
$Gender = ($_POST['Gender']);
if(empty($_POST['UserName'])){
$UserName = '';
$flag=1;
} else
$UserName = ($_POST['UserName']);
if(empty($_POST['Password'])){
$Password = '';
$flag=1;
} else
$Password = ($_POST['Password']);
if(empty($_POST['reEnterPassword'])){
$reEnterPassword = '';
$flag=1;
} else
$reEnterPassword = ($_POST['reEnterPassword']);
if(empty($_POST['EmailAdd'])){
$EmailAdd = '';
$flag=1;
} else
$EmailAdd = ($_POST['EmailAdd']);
if(empty($_POST['reEnterEmailAdd'])){
$reEnterEmailAdd = '';
$flag=1;
} else
$reEnterEmailAdd = ($_POST['reEnterEmailAdd']);
$sql = " INSERT INTO User(FirstName, LastName, UserName, Password, reEnterPassword, EmailAdd, reEnterEmailAdd)
VALUES ('$FirstName', '$LastName', '$UserName', '$Password', '$reEnterPassword', '$EmailAdd', '$reEnterEmailAdd'); ";
if($flag != 1){
$result = mysql_query($sql);
if (!$result){
die('Invalid Input: ' . mysql_error().$sql);
}
else{
echo "<script> alert('Successfully Added'); </script> ";
}
}
?>
<head>
<!-- bootstrap plugin -->
<link href="../css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<link href="../css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />
<link href="../css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- jquery plugin -->
<script src="../js/jquery-1.11.1.js"></script>
<!-- Site body css -->
<style type="text/css">
#SiteBody{
width: 1100px;
margin: 0 auto;
}
</style>
</head>
<body>
<center>
<div class="hero-unit">
<!-- Start header -->
<img src="../images/logo.png"/>
<!-- End header -->
<div id="SiteBody">
<!--2nd Header Bar!-->
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="#">Sign-Up Form</a>
<!--Nav bar items!-->
<p class="navbar-text pull-right">
<a href="../homePage.php" class="navbar-link"> Home </a>
</p>
</div>
</div>
<!--2nd Header Bar END !-->
<div class="span9">
<blockquote>
<p><strong> Please fill-up the following: </strong></p>
</blockquote>
<form class="form-horizontal" action="../php/signUp.php" method="post">
<fieldset>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="FirstName"></label>
<div class="controls">
First Name: <input id="FirstName" name="FirstName" type="text" placeholder="Enter First Name" class="input-xlarge" required="">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="LastName"></label>
<div class="controls">
Last Name: <input id="LastName" name="LastName" type="text" placeholder="Enter Last Name" class="input-xlarge" required="">
</div>
</div>
<!-- Select Basic -->
<div class="control-group">
<label class="control-label" for="Gender"></label>
<div class="controls">
Type: <select id="Gender" name="Gender" class="input-xlarge">
<option>Select Gender</option>
<option>Male</option>
<option>Female</option>
</select>
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="UserName"></label>
<div class="controls">
User Name: <input id="UserName" name="UserName" type="text" placeholder="Enter User Name" class="input-xlarge" required="">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="Password"></label>
<div class="controls">
Password: <input id="Password" name="Password" type="password" placeholder="enter password" class="input-xlarge" required="">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="reEnterPassword"></label>
<div class="controls">
Re-type Password: <input id="reEnterPassword" name="reEnterPassword" type="password" placeholder="re-enter password" class="input-xlarge" required="">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="EmailAdd"></label>
<div class="controls">
E-mail: <input id="EmailAdd" name="EmailAdd" type="text" placeholder="Enter Email Address" class="input-xlarge" required="">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="reEnterEmailAdd"></label>
<div class="controls">
Re-type E-mail: <input id="reEnterEmailAdd" name="reEnterEmailAdd" type="text" placeholder="Re-Enter Email Address" class="input-xlarge" required="">
</div>
</div>
<!-- Button (Double) -->
<div class="control-group">
<div class="controls">
<but`enter code here`ton class="btn btn-success"> Confirm </button>
</div>
</div>
</center>
</fieldset>
</form>
</body>
</html>