NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php

define('DB_PATH', 'localhost'); //設定資料庫位置
define('DB_USER', 'admin'); //設定資料庫帳號
define('DB_PASSWORD', '2ruixdgi'); //設定資料庫密碼
define('DB_NAME', 'demo'); //設定資料庫名稱
$link = new PDO('mysql'.':host='.DB_PATH.';charset=UTF8;dbname='.DB_NAME, DB_USER, DB_PASSWORD);
$link->query('SET NAMES UTF8')->execute();
$data = array(':name' => $_POST[name], ':content' => $_POST[content]);
if ($_GET[act]=='del')
{
$id = $_GET[id];
$query = $link->prepare('DELETE FROM `book` WHERE `id` = :id;');
$query->execute(array(':id' => $id));
}
var_dump(2);
if ($_GET[act]=='upd')
{

$id = $_GET[id];

$query = $link->prepare('SELECT * FROM book WHERE id = :id;');
$query->execute(array(':id' => $id));
$result2 = $query->fetch(PDO::FETCH_OBJ);
var_dump(1);


}

if ($_GET[act]=='exeupd')
{

$id = $_GET[id];
$query = $link->prepare('UPDATE `book` SET
`name` = :name,
`content` = :content,
`updtime` = CURRENT_TIMESTAMP
WHERE `id` = :id;');
$query->execute(array(':id' => $id, ':name' => $_POST[name], ':content' => $_POST[content]));
var_dump(3);
}
if ($_GET[act]=='ins')
{

$query = $link->prepare('INSERT INTO `book` (`name`, `content`, `updtime`) VALUES (:name, :content, CURRENT_TIMESTAMP);');
$query->execute($data);
var_dump(4);

}
var_dump(5);
$query = $link->prepare('SELECT * FROM book');
$query->execute();
$result = $query->fetchAll(PDO::FETCH_OBJ);
var_dump(6);
$username = $_POST['u'];
$password = $_POST['p'];


?>
<html>
<head>
<meta charset='utf-8' />
</head>
<body>
<?php if ($username == 'admin' && $password =='54321'): ?>

<script>alert('登入成功');</script>

<?php else: ?>

<form method='POST' action='demo.php'>
<p>帳號: <input type='text' name='u' /></p>
<p>密碼: <input type='password' name='p' /></p>
<input type='submit' />
</form>
<?php endif; ?>


<?php foreach($result as $i => $v): ?>

<p><?php echo $i+1; ?>.<?php echo $v->content; ?> </br>
<?php echo $v->name; ?>在<?php echo $v->updtime; ?>
</p>
<a href='demo.php?act=del&id=<?php echo $v->id; ?>'>刪除</a> | <a href='demo.php?act=upd&id=<?php echo $v->id; ?>'>修改</a>
<hr>
<?php endforeach; ?>
<?php if($_GET['act']=='upd'): ?>

<form method='POST' action='demo.php?act=exeupd&id=<?php echo $_GET['id']; ?>'>
<p>名稱: <input type='text' name='name' value='<?php echo $result2->name; ?>'/></p>
<p>內容: <textarea name='content'><?php echo $result2->content; ?></textarea></p>
<input type='submit' />
</form>
<?php else: ?>
<?php var_dump($_GET['act']); ?>
<form method='POST' action='demo.php?act=ins'>
<p>名稱: <input type='text' name='name' /></p>
<p>內容: <textarea name='content'></textarea></p>
<input type='submit' />
</form>
<?php endif; ?>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.