Я пытаюсь получить свою форму для отправки в мою базу данных, но я действительно новичок в PHP, и я не могу понять, где я ошибаюсь. Я знаю, что я подключаюсь к базе данных, но как только я нажимаю кнопку «Отправить», я получаю. Эта страница не может быть отображена и ошибок нет. Я снова собрал и прочитал руководство по PHP, но я все еще застрял.Форма не отправляется в базу данных
<body><div id="form-container">
<h1 id="form-name">Application for Employment</h1>
<form action="senddata2.php" method="post" id="dynamic-form" class="ui-sortable">
<div class="row" style="display: block; position: relative;">
<label class="field" for="date">Date:<div class="rqrd">*</div></label>
<span class="date"><span class="textField"><input type="text" id="date" name="date" data="{"validate":{"required":true,"date":true,"messages":{"required":"This field is required"}}}"></span></div>
<div class="row" style="display: block; position: relative;">
<label for="position">Position Applied For:<div class="rqrd">*</div></label>
<input id="position" name="position" class="text" data="{"validate":{"required":true,"messages":{"required":"This field is required"},"maxlength":"50"}}"></div>
<div class="row" style="display: block; position: relative;">
<label for="referral">Referral Source:<div class="rqrd">*</div></label>
<span class="dropDown"><select id="referral" name="referral" data="{"validate":{"required":true,"messages":{"required":"This field is required"}}}"><option value="Advertisement ">Advertisement </option><option value="Employment Agency">Employment Agency</option><option value="Friend">Friend</option><option value="Walk-In">Walk-In</option><option value="Relative">Relative</option><option value="Other">Other</option></select></span></div>
<input type="submit" name="formSubmit" value="Submit" class="button blue" id="submit-form">
<div class="clr"></div>
</form>
<?php
$dbh = new pdo('sqlsrv:Server=XXXX,1433;database=XXX',
'XXX',
'XXX',
$tsql = "INSERT INTO testtable (Date, Position, Referral) VALUES (?, ?, ?)";
$stmt = $dbh->prepare($tsql);
if (!$stmt) {
echo "\nPDO::errorInfo():\n";
print_r($db->errorInfo());
}
$stmt->execute(array($_REQUEST['Date'], $_REQUEST['Position'], $_REQUEST['Referral']));
if (!$stmt) {
echo "\nPDO::errorInfo():\n";
print_r($stmt->errorInfo());
}
/* The following call to closeCursor() may be required by some drivers */
$stmt->closeCursor();
// and now we're done; close it
$dbh = null;
?>
... и 'senddata2.php' определенно существует на вашем сервере? Правильно? – naththedeveloper
@FDL Правильно, да. – user2438493