For some reason this just isn't inserting...
HTML snippet:
<form name="testimonials_form" method="post" action="insert/">
Name
<input type="text" name="from" maxlegnth="100" />
Location
<input type="text" name="where" maxlegnth="100" />
Text Snippet
<input type="text" name="text" maxlegnth="255">
<input type="submit" name="submit" value="Continue" />
</form>
PHP Snippet:
<?php
$from = $_POST['from'];
$where = $_POST['where'];
$text = $_POST['text'];
if (!$from || !$where || !$text) {
$error = "You have missed some fields.";
$solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>.";
} else {
$data_array = array( ':from' => $from, ':where' => $where, ':text' => $text);
$insert_testimonial = $connect->prepare("INSERT INTO `testimonials` (text, from, where) VALUES (:text, :from, :where)");
$insert_testimonial->execute($data_array);
$amount = $insert_testimonial->rowCount();
if ($amount < 1) {
$error = "Something went wrong.";
$solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>.";
} else {
header ("Location: ../");
}
}
?>
All I keep getting back is my custom error "Something went wrong." so there's no 500 error (internal server error) and if I echo $from, $where and $text it displays what I typed in the form, I've re-written it about 5 times in case I wrote it wrong or something but still no luck. I know there can't be a symbol missing or in the wrong place since it would return a 500 error.
Does anyone have any clue as to what's up with it? I've written codes like this countless times but this just doesn't seem to be working, so I must be missing something.