Skip to content

Instantly share code, notes, and snippets.

@arn-ob
Created April 7, 2016 08:23
Show Gist options
  • Save arn-ob/1c597f7a4a8562f9150455cad41c80c3 to your computer and use it in GitHub Desktop.
Save arn-ob/1c597f7a4a8562f9150455cad41c80c3 to your computer and use it in GitHub Desktop.
Use Html to store data at SQL by using PHP
<html>
<?php
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$cn = mysql_connect($servername, $username, $password);
if (!$cn)
{
die("could not connect".mysql_error());
}
else
{
echo "connected to the server successfully";
}
echo "<br>";
mysql_select_db("ewu",$cn);
//$q="insert into student values ('Emon','Dhaka')";
$q ="INSERT INTO student (name, address) VALUES ('$_POST[name]', '$_POST[address]')";
$mq = mysql_query($q,$cn);
if(!$mq)
{
die("Connection failed: ".mysql_error());
}
else
{
echo "data inserted successfuly";
}
mysql_close($cn);
?>
<p><a href="index.html">Click here </a></p>
</html>
<html>
<head></title>php form processing</title></head>
<form action="action.php" method="post">
Name:<input type="text" name="name" /><br />
Address<input type="text" name="address" /><br />
<input type="submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment