I am fairly new to PHP and I am trying to save input from a user into a mysql database. I followed a tutorial online on how to do it, but every time I enter the user's info, the website tells me it failed. The only thing that I can think of is the host name(I copied and pasted it from phpadmin).Please let me know if there is something wrong.
contact.html
<section id="mid_section">
<div id="boxes">
<h1>
Leave your information here for a quick reponse:
</h1>
<br/>
<form id="myform" action="userinfo.php" method="post">
Name:<input type="text" value="name">
Email:<input type="email" value="email">
Phone:<input type= "tel" value="phone(opt)">
<button id="sub">Submit</button>
</form>
db.php
<?php
$conn = mysql_connect('custsql.eigbox.net','username','password');
$db= mysql_select_db('visitors');
?>
userinfo.php
<?php
include_once('db.php');
$name =$_POST['name'];
$email =$_POST['email'];
$phone =$_POST['phone'];
if(mysql_query("INSERT INTO users (name,email,phone) VALUES ('$name','$email','$phone')"))
echo"successfully inserted";
else
echo "failed";
?>
myscript.js
$("#sub").click(function(){
$.post($("#myform").attr("action"), $("#myform:input").serializeArray(), function(info){$("#result").html(info);});
});
$("#myform").submit(function(){
return false;
});