Commit 1dcb1ad9 authored by rama chandra's avatar rama chandra
Browse files

added db insert command to all php files

parent 2f2ea6f8
<?php <?php
class db{ $con = mysqli_connect("localhost","root","","blood");
private $host = "localhost"; // Check connection
private $dbname = "blood"; if (mysqli_connect_errno())
private $username = "root"; {
private $password = ''; echo "Failed to connect to MySQL: " . mysqli_connect_error();
protected $con; }
public function __construct(){
try{
// new PDO("msql:host=localhost;dbname=messenger", "root","");
$this->con = new PDO("mysql:host=".$this->host. ";dbname=".$this->dbname, $this->username, $this->password );
}catch(Exception $e){
echo "DataBase Connection Problem: ".$e->getMessage();
}
}
}
?> ?>
\ No newline at end of file
<?php <?php
$con = mysqli_connect("localhost", "root", "", "blood"); require('db.php');
$status = "";
if($con === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$name = $_POST['name']; $name = $_POST['name'];
$blood=$_POST['blood']; $blood=$_POST['blood'];
$age = $_POST['age']; $age = $_POST['age'];
...@@ -16,7 +12,7 @@ $ld= $_POST['ago']; ...@@ -16,7 +12,7 @@ $ld= $_POST['ago'];
$sql = "INSERT INTO bloo (uname,blood,age,mobile,city,dd) VALUES ('$name', '$blood', $age,'$mobile','$city','$ld')"; $sql = "INSERT INTO bloo (uname,blood,age,mobile,city,dd) VALUES ('$name', '$blood', $age,'$mobile','$city','$ld')";
$result=mysqli_query($con,$sql); $result=mysqli_query($con,$sql) or die(mysql_error());
if($result==true) if($result==true)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment