PHP脚本将回显语句,但不会从模态中将数据插入表中

时间:2017-10-08 03:33:53

标签: php mysql forms modal-dialog

我正在构建一个简单的客户端管理系统,允许用户将客户端数据输入到以模态填充的表单中。这个想法是当用户通过单击Create New Client完成模式中的表单时,新的客户端信息将存储到名为client的预定义mysql表中。我在整个网站使用几乎相同的PHP脚本来创建新用户,工作正常。

与此脚本的主要区别在于,它是从包含在div中的模式中的表单中调用的。这可能会阻止我的脚本跟踪查询吗?

除了我自己定义的if else调用之外,没有任何错误消息。数据将在Submit上回显,但信息实际上不会插入到mysql中的数据中。我对html和css之外的任何事情都很陌生,所以当我继续处理这个旅程时,任何帮助都将受到极大的赞赏和回应。参考代码

newclient.php

<?php
session_start();
include 'dbh.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);

$comname = $_POST['comname'];
$primcon = $_POST['primcon'];
$addr = $_POST['addr'];
$city = $_POST['city']; 
$state = $_POST['state'];
$zip = $_POST['zip'];
$phn = $_POST['phn'];
$websi = $_POST['websi'];
$email = $_POST['email'];
$activ = $_POST['activ'];

$sql = "INSERT INTO client (comname, primcon, addr, city, state, zip, phn, 
websi, email, activ ) 
VALUES ('$comname', '$primcon', '$addr', '$city', '$state', '$zip', '$phn', 
'$websi', '$email', '$activ')";
$result = mysqli_query($conn, $sql);

echo $comname;
echo $primcon;
echo $addr;
echo $city;
echo $state;
echo $zip;
echo $phn;
echo $websi;
echo $email;
echo $activ;

//header("Location: login.html");

admin.html - 用户实际创建新客户端(仅限模式内容)

<div class="modal-content">
<div class="modal-header">
  <span class="close">&times;</span>
  <h2>New Client Registration</h2>
</div>

<div class="modal-body">
    <form align="center" 
action="http://localhost:1234/housenotes/newclient.php" method="POST">
            <input type="text" placeholder="Company Name" name="comname" 
required> 
            <input type="text" placeholder="Primary Contact" name="primcon" 
required> 
            <input type="text" placeholder="Street Address" name="addr" 
required> <br>
            <input type="text" placeholder="City" name="city" required>
            <input type="text" placeholder="State" name="state" required> 
            <input type="text" placeholder="Zip" name="zip" required> <br>
            <input type="text" placeholder="Phone Number" name="phn" 
required> 
            <input type="text" placeholder="Website" name="websi" required>
            <input type="text" placeholder="Email" name="email" required>
<br>  
            <input type="radio" name="activ" value="Potential" checked> 
Potential
            <input type="radio" name="activ" value="Engaged"> Engaged
            <input type="radio" name="activ" value="Active"> Active<br>  
            <button type="submit" class="button" style="width:15%;">Create 
New Client</button>

    </form>

</div>
<div class="modal-footer">
  <h3>housenotes</h3>
</div>

再一次,任何帮助将不胜感激!提前致谢!

0 个答案:

没有答案