Code: Select all
<?php
$name = $_POST['name'];
$contactinfo = $_POST['contactinfo'];
$problem = $_POST['problem'];
$requirements = $_POST['requirements'];
$connect = mysql_connect("localhost", "root", "");
mysql_select_db("elektrisolutionsdb", $connect);
$insert_query = "insert into workrequests(date,name,contactinfo,problem,requirements) VALUES(NOW(),$name, $contactinfo, $problem, $requirements)";
$sql = mysql_query($insert_query) or die("SQL ERROR: ".mysql_error());
if($sql) {
echo"<p>Thank you for submitting a work request form to Elektri.</p>";
}
else {
echo"<p>An error has occured. Your work request has not been processed.</p>";
}
?>
The database is comprised of an int id column, two varchar columns for the name and contact info, two text columns for the problem and requirements, and a date column for the time it was processed.
I am using XAMPP's mysql and apache for this.
My two questions are these:
Am I not supposed to use a textarea tag inside of a form?
How do I handle the @ symbol inside of an insert?