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

added db insert command to all php files

parent 2f2ea6f8
<?php
class db{
private $host = "localhost";
private $dbname = "blood";
private $username = "root";
private $password = '';
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();
}
}
}
$con = mysqli_connect("localhost","root","","blood");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "root", "", "blood");
if($con === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
require('db.php');
$status = "";
$name = $_POST['name'];
$blood=$_POST['blood'];
$age = $_POST['age'];
......@@ -16,7 +12,7 @@ $ld= $_POST['ago'];
$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)
{
......
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