我正在学习编写网页代码而我遇到了一个不知道如何修复它的问题。我认为我做得很好,但它没有向服务器发送数据。我买了一个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';
}
?>
我添加一个会话变量来测试文件是否已经执行但是它仍然没有显示。
答案 0 :(得分:1)
在PHP中,变量区分大小写。除非我弄错了本机PHP会话变量MainLayout
。因此,如果这是您上面确切的PHP代码,并且您希望它做的是增加键'var'的值,那么您需要使用$_SESSION
。
看起来更像是这样。
$_SESSION['var']
当然,要测试PHP脚本是否正确增加了键值,那么您需要向客户端或文本文件等输出session_start();
if(isset($_SESSION['var']))
{
$_SESSION['var']++;
}
else
{
$_SESSION['var'] = 0;
}
或其他指示。
在发布我的回答时,你一定是在编辑你的问题。但我会将你的最后一行PHP改为:
$_SESSION['var']
只是为了让你的输出更具相关性和帮助。
我会在评论中留下这个,但我没有足够的声誉点。 阅读您对问题的进一步评论,检查您的PHP脚本是否正在运行可能会有所帮助。我会查看Chrome开发人员工具的网络标签,看看您是否找到了正确的脚本以及返回了哪些错误。