<form method="post" action="http://www.domain.com/insertcontacts.php" name="Contact Form">
The variables being posted are: realname, email, phone.
The form never changed the entire time the php was being changed, so I know it's not the problem.
Here is the php script:
Code: Select all
<h1>Testing MYSQL Connection...</h1>
<body>
<?
$connection = mysql_connect("webhostserver","database","password");
if (!$connection) {
echo "Couldn't make a connection!";
exit;
}
$db = mysql_select_db("database", $connection);
if (!$db) {
echo "Couldn't select database!";
exit;
}
$sql = "INSERT INTO 'database'.'contacts' ('contact_name', 'contact_email', 'contact_phone') VALUES ('$_POST["realname"]', '$_POST["email"]', '$_POST["phone"]')";
if (!mysql_query($sql,$connection))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
$output = "SELECT `contact_name`,`contact_email`,`contact_phone`,`initial_contact` FROM `database` LIMIT 0, 30 ";
$sql_result = mysql_query($output,$connection);
echo "<TABLE BORDER=1>";
echo "<TR><TH>contact_name</TH><TH>contact_email</TH><TH>contact_phone</TH><TH>initial_contact</TH>";
while ($row = mysql_fetch_array($sql_result)) {
$contact_name = $row["contact_name"];
$contact_email = $row["contact_email"];
$contact_phone = $row["contact_phone"];
$initial_contact = $row["initial_contact"];
echo "<TR><TD>$contact_name</TD><TD>$contact_email</TD><TD>$contact_phone</TD><TD>$initial_contact</TD></TR>";
}
echo "</TABLE>";
mysql_free_result($sql_result);
mysql_close($connection);
?>
</body>
I have done as much research as I could before posting here. I am confused because it seems some examples use backslashes in their queries and others do not. But while I am curious about that, it isn't my primary concern right now.