I need the following form to right to MySQL table "table1" and columns "name" "email" and "comment".
<form method="post" action="sign.php" class="pure-form pure-form-stacked">
<fieldset>
<label for="name">Your Name</label>
<input id="name" type="text" placeholder="Your Name" name="name">
<label for="email">Your Email</label>
<input id="email" type="email" placeholder="Your Email" name="email">
<label for="comment">Your Comments</label>
<input id="comment" type="text" placeholder="Your Comments" name="comment">
<a href="thanks.html" button type="submit" class="pure-button">SUBMIT</button>
</a>
</fieldset>
</form>
My PHP File looks like this:
<html>
<body>
<?php
$myUser = "dbuser";
$myPassd = "********";
$myDB = "dbname";
$myserver = "192.168.1.80:3306";
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
// Create connection
$dbhandle = mysql_connect($myserver,$myUser,$myPassd)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
//select a database to work with
$selected = mysql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//if (mysqli_connect_errno()) {
//echo "Failed to connect to MySQL: " . mysqli_connect_error();
//}
//echo "connected";
$sql = "INSERT INTO signatures (name, comment) VALUES ( $name, $comment)";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "record added";
mysql_close($dbhandle);
?>
</body>
</html>
I also need this to redirect to another html page after it run.