我正在學習編碼網頁,我陷入了一個問題,不知道如何解決它。我認爲我做得很好,但不會將數據發送到服務器。我買了一個html模板,我正在研究它。當我修改表單標籤中的動作時,它不發送數據。這是我的HTML表單(整頁here):數據沒有被髮送到數據庫
<form action="includes/registerhandler.php" method="POST" role="form" id="form_register" enctype="multipart/form-data">
<!--<div class="form-register-success">
<i class="entypo-check"></i>
<h3>You have been successfully registered.</h3>
<p>We have emailed you the confirmation link for your account.</p>
</div>-->
<div class="form-steps">
<div class="step current" id="step-1">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-user"></i>
</div>
<input type="text" class="form-control" name="FullName" id="name" placeholder="Full Name" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-phone"></i>
</div>
<input type="text" class="form-control" name="Phone" id="phone" placeholder="Phone Number" data-mask="phone" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-calendar"></i>
</div>
<input type="text" class="form-control" name="B-D" id="birthdate" placeholder="Date of Birth (DD/MM/YYYY)" data-mask="date" autocomplete="off" />
</div>
</div>
<div class="form-group">
<button type="button" data-step="step-2" class="btn btn-primary btn-block btn-login">
<i class="entypo-right-open-mini"></i>
Next Step
</button>
</div>
<div class="form-group">
Step 1 of 2
</div>
</div>
<div class="step" id="step-2">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-user-add"></i>
</div>
<input type="text" class="form-control" name="UserName" id="username" placeholder="Username" data-mask="[a-zA-Z0-1\.]+" data-is-regex="true" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-mail"></i>
</div>
<input type="text" class="form-control" name="Email" id="email" data-mask="email" placeholder="E-mail" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-lock"></i>
</div>
<input type="password" class="form-control" name="PassWord" id="password" placeholder="Choose Password" autocomplete="off" />
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-block btn-login">
<i class="entypo-right-open-mini"></i>
Complete Registration
</button>
</div>
<div class="form-group">
Step 2 of 2
</div>
</div>
</div>
</form>
這是我的PHP腳本:
<?php
include 'connect.php';
if(isset($_POST)){
$FullName = $_POST['FullName'];
$UserName = $_POST['UserName'];
$B-D = $_POST['B-D'];
$Gender = $_POST['Gender'];
$Address = $_POST['Address'];
$Phone = $_POST['Phone'];
$Email = $_POST['Email'];
$City = $_POST['City'];
$Country = $_POST['Country'];
$PassWord = $_POST['PassWord'];
$repons = $bdd->query('select count(*) from user where Username =\'' .$UserName. '\'')->fetchColumn();
if($repons == 1){
echo 'user already exist';
}
else{
$req = $bdd->prepare('INSERT INTO user VALUES ("",:UserName,:PassWord,:B-D,:Email,:FullName,:Phone,:Gender,:Address,:City,:Country)');
$req->execute(
array( ':FullName' => $FullName, ':UserName' => $UserName, ':B-D' => $BirthDate, ':Gender' => $Gender, ':Phone' => $Phone, ':Email' => $Email, ':City' => $City, ':Country' => $Country, ':PassWord' => $PassWord, ':Address' => $Address));
$idp = $bdd->lastInsertId();
echo 'you are now a member confirmation email sent';
}
else{
echo 'submit is not set';
}
?>
我添加了一個會話變量,如果該文件已經執行到測試,但它仍然沒」 t顯示一個東西。
您需要更具體一點,讓我們知道您期待的事情以及實際發生的事情? –
實際上php代碼根本不能執行,我不知道爲什麼。 – Igzo
PHP變量區分大小寫。 '$ _session'和'$ _SESSION'是完全不同的東西。 –