也许有人可以帮助我看到我正在犯的错误。这是一个非常简单的形式,我无法弄清楚为什么它没有正确提交。
数据库似乎连接得很好(它在config.php文件中定义),因为有几个表单项从数据库中提取。有什么想法吗?
非常感谢。
<?php
if (isset($_POST['submit']) && $_POST['submit'] == 'createAccount') {
// Create the new contact
$name = $mysqli->real_escape_string($_POST['name']);
$phone = $mysqli->real_escape_string($_POST['phone']);
$email = $mysqli->real_escape_string($_POST['email']);
$stmt = $mysqli->prepare("
INSERT INTO
providers(
name,
phone,
email
) VALUES (
?,
?,
?
)");
$stmt->bind_param('sss',
$name,
$phone,
$email
);
$stmt->execute();
}
?>
<div class="container">
<div class="content">
<?php echo mysql_error() ?>
<p>
SEARCH FOR A CONTACT
</p>
</div>
<div class="content">
<p>
ADD A CONTACT
<form action="" method="post">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="usersName">Contact Name</label>
<input type="text" class="form-control" name="name" />
<span class="help-block">Company or Person's Name</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="usersEmail">Phone Number</label>
<input type="text" class="form-control" name="phone" />
<span class="help-block">Please provide contact's phone number.</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="text">Address</label>
<input type="text" class="form-control" name="address" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="city">City</label>
<input type="text" class="form-control" name="city" />
<label for="state">State</label>
<input type="text" class="form-control" name="state" />
<label for="zip">Zip Code</label>
<input type="zip" class="form-control" name="zip" />
</div>
</div>
</div>
<p>Please provide the installations this provider is close to, starting with the closest. You do not need to provide more than one.</p>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="text">Installation 1</label>
<?php
$result = mysqli_query($mysqli,"SELECT * FROM installations ORDER BY name");
echo '<select name="installation_id" class="btn-select">';
echo '<option disabled selected> -- select an option -- </option>';
while($row = mysqli_fetch_array($result)) { ?>
<option value="<?=$row['id']?>" > <? echo $row['name'] ?></option>
<?php }
echo '</select>';
?>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="text">Installation 2</label>
<?php
$result = mysqli_query($mysqli,"SELECT * FROM installations ORDER BY name");
echo '<select name="installation_id2" class="btn-select">';
echo '<option disabled selected> -- select an option -- </option>';
while($row = mysqli_fetch_array($result)) { ?>
<option value="<?=$row['id']?>"> <? echo $row['name'] ?></option>
<?php }
echo '</select>';
?>
</div>
</div>
</div>
<p>Please choose a provider type for this contact. Contacts can often provide more than one service, please choose all that fit this contact.</p>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="text">Provider Type</label>
<?php
$result = mysqli_query($mysqli,"SELECT * FROM provider_type ORDER BY name");
echo '<select name="provider_type1" class="btn-select">';
echo '<option disabled selected> -- select an option -- </option>';
while($row = mysqli_fetch_array($result)) { ?>
<option value="<?=$row['id']?>"> <? echo $row['name'] ?></option>
<?php }
echo '</select>';
?>
</div>
</div>
<div class="col-md-4">
</div>
<button type="input" name="submit" value="createAccount" class="btn btn-success btn-icon"><i class="fa fa-check-square-o"></i> Create Contact</button>
<button type="button" class="btn btn-warning btn-icon" data-dismiss="modal"><i class="fa fa-times-circle"></i> Cancel</button>
</form>
</p>
</div>