Created
April 7, 2016 08:23
-
-
Save arn-ob/1c597f7a4a8562f9150455cad41c80c3 to your computer and use it in GitHub Desktop.
Use Html to store data at SQL by using PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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