-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsavedata.php
30 lines (30 loc) · 955 Bytes
/
savedata.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// from: http://php.thedemosite.co.uk/
// version 1.2
include("clean_input.php");
if( ($username=="") OR ($password=="") )
{
include("addauser.php");
exit;
}
include("config.php");
include("dbc.php");
$qadd = "INSERT INTO members
(id, password, username)
VALUES ('1', 'test', 'test') ";
$qupdate = "UPDATE members
SET password =:password,
username =:username WHERE id = '1'";
$dbc = dbc::instance();
$result = $dbc->prepare("SELECT * from members where id = '1' ");
$rows = $dbc->executeGetRows($result);
if(count($rows))// check the single record exists
{
$result = $dbc->prepare($qupdate); // set to update original record
$result->bindParam(':username', $username, PDO::PARAM_STR);
$result->bindParam(':password', $password, PDO::PARAM_STR);
}
else $result = $dbc->prepare($qadd); // if not set to add an initial record
$result = $dbc->execute($result);
include("addauser.php");
?>