-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomment_test.php
73 lines (73 loc) · 2.29 KB
/
comment_test.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require_once 'header.php';
if($_POST['uid']){
$uid_flag = 1;
$uid = $_POST['uid'];
$id = $uid - 100000;
}else{
$uid = 100000;
}
?>
<div class="container">
<div class="row">
<div class="col-md-6">
<form action="comment_test.php" method="POST">
<p>表示したいUID<input type="text" name="uid" value="<?php print($uid)?>">
<input type="submit" value="検索"></p>
</form>
<br>
<?php
session_start();
if ($uid_flag == 1) {
$conn = "host=localhost dbname=tpro_alpha user=tpro password=pw4tPro-DB";
$link = pg_connect($conn);
if (!$link) {
die('接続失敗です。'.pg_last_error());
}
print('接続に成功しました。<br><br>');
/*
$sql = "INSERT INTO users (name, screen_name, uid, password_hash, bio, salt) VALUES ('yaster5', 'yaster5', 100004, 'password_hash','bioのてすと5','salt5')";
$result_flag = pg_query($sql);
if (!$result_flag) {
die('INSERTクエリーが失敗しました。'.pg_last_error());
}
*/
$result = pg_query('SELECT id,name,screen_name,password_hash,email,uid,bio FROM users ORDER BY id');
if (!$result) {
die('クエリーが失敗しました。'.pg_last_error());
}
$rows = pg_fetch_array($result, $id, PGSQL_ASSOC);
if(isset($rows['id'])){
print('<table border="1">');
print('<tr><td>id</td><td>'.$rows['id'].'</td></tr>');
print('<tr><td>name</td><td>'.$rows['name'].'</td></tr>');
print('<tr><td>screen_name</td><td>'.$rows['screen_name'].'</td></tr>');
print('<tr><td>password_hash</td><td>'.$rows['password_hash'].'</td></tr>');
print('<tr><td>email</td><td>'.$rows['email'].'</td></tr>');
print('<tr><td>uid</td><td>'.$rows['uid'].'</td></tr>');
print('<tr><td>bio</td><td>'.$rows['bio'].'</td></tr></table><br>');
}else{
print('UID"'.$uid.'"は存在しないUIDです。<br><br>');
$uid_flag = 2;
}
$close_flag = pg_close($link);
if ($close_flag){
print('切断に成功しました。<br><br>');
}
if ($uid_flag != 2) {
?>
<form action="postbio.php" method="post">
<p>変更後のBIO<input type="text" name="bio" value="bio text">
<input type="hidden" name="id" value="<?php print($uid)?>">
<input type="submit" value="送信"></p>
</form>
<?php
}
}
?>
</div>
</div>
</div>
<?php
require_once 'footer.php';
?>