Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
KLUGLUG
Blood Service Portal
Commits
1dcb1ad9
Commit
1dcb1ad9
authored
Nov 14, 2019
by
rama chandra
Browse files
added db insert command to all php files
parent
2f2ea6f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
db.php
View file @
1dcb1ad9
<?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
insert.php
View file @
1dcb1ad9
<?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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment