-1
從我的形式獲取數據我有PHP代碼的問題,我想從我的HTML表單讀取數據和我不斷收到空 這裏是我的PHP代碼不能使用PHP _ POST方法
<html>
<body>
<?php
$dbhost="127.0.0.1";
$dbuser="root";
$dbpass="";
$dbname="mss";
$connection=mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
if(mysql_errno()) {
die("Database Connection failed:" . mysql_error() . "(" . mysql_errno() .")");
}
?>
first Name : <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $first = $_REQUEST['firstName']; echo $first; } ?><br>
last Name : <?php $last = (isset($_REQUEST['lastName']) ? $_REQUEST['lasttName']: "hello"); echo $last; ?><br>
email : <?php $email = (isset($_REQUEST['email']) ? $_REQUEST['email']: "hello"); echo $email; ?><br>
street address : <?php $streetAddress = (isset($_REQUEST['streetAddress']) ? $_REQUEST['streetAddress']: "hello"); echo $streetAddress; ?><br>
city : <?php $city = (isset($_REQUEST['city']) ? $_REQUEST['city']: "hello"); echo $city; ?><br>
state : <?php $state = (isset($_POST['state']) ? $_POST['state']: "hello"); echo $state; ?><br>
Zip code : <?php $zipCode = (isset($_POST['zipCode']) ? $_POST['zipCode']: "hello"); echo $zipCode; ?><br>
college : <?php $college = (isset($_POST['college']) ? $_POST['college']: "hello"); echo $college; ?><br>
userName : <?php $username = (isset($_POST['username']) ? $_POST['username']: "hello"); echo $username; ?><br>
password : <?php $password = (isset($_POST['password']) ? $_POST['password']: "hello"); echo $password; ?><br>
</body>
和下面是形式
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add New Employee</title>
<script type="text/javascript" src="new employee validate.js"></script>
</head>
<body>
<h1 style="font-family:Verdana, Geneva, sans-serif; font-size:24px;" align="center">Add New Employee</h1>
<form name="AddNewEmployee" onSubmit="return validation()" action="AddEmployeePhp.php" method= "POST">
<table align="center">
<tr>
<td><font color="#FF0000">*</font> First Name:</td>
<td><input type="text" id="firstName" name ="firstName" required = "required"/></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Last Name:</td>
<td><input type="text" id="lastName" name ="lastName" required = "required"/></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>E-mail Address:</td>
<td><input type="text" id="email" name="email" required = "required"/></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Cell Phone Number:</td>
<td><input type="text" id="phone" name="phone" required = "required"/></td>
</tr>
<tr>
<td>Street Address:</td>
<td><input type="text" id="streetAddress" name= "streetAddress"/></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" id="city" name = "city"/></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" id="state" name ="state"/></td>
</tr>
<tr>
<td>Zip Code:</td>
<td><input type="text" id="zipCode" name="zipCode"/></td>
</tr>
<tr>
<td>College:</td>
<td><input type="text" id="college" name="college"/></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>User Name:</td>
<td><input type="text" id="username" name = "username" required = "required"/></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Password:</td>
<td><input type="password" id="password" name = "password" required = "required"/> </td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Confirm Password:</td>
<td><input type="password" id="confirmPassword" required = "required"/></td>
</tr>
<tr>
<td>
<p> </p>
</td>
<td>
<p> </p>
</td>
</tr>
<tr>
<td><input type="submit" name="Create Employee" value="Create Employee"/></td>
<td><input type="button" name="Clear All" value="Clear All" /></td>
</tr>
</table>
</form>
<label> Note: All <font color="#FF0000">*</font> Fields are required please fill them all</label>
</body>
任何SUG我的HTML代碼gestions?
請粘貼後考慮格式化您的代碼!現在你到底在哪裏? – FAS
你有沒有嘗試'var_dump($ _ SERVER ['REQUEST_METHOD'],$ _POST)'? –
我有點難以閱讀所有這些混亂的代碼。我的眼睛正在爭取從左到右。 –