Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@takahiro0216

ボタンを押した時に処理を実行させたい時

More than 1 year has passed since last update.

今回は投稿内容を編集し、編集完了ボタンを押したらdbの投稿内容を書き換える(更新する)というもの

if文で条件を指定してからデータベースへアクセスし書き換えるという流れ

<?php
/ post_rewriteはinputタグのname属性/

if(isset($_POST['post_rewrite'])){
$statement = $db->prepare('UPDATE posts SET message=? WHERE id=?');
$statement->execute(array($_SESSION['message'],$_SESSION['posts_id']));
?>

HTML文(ボタンの部分のみ)

これで修正完了するボタンを押すとphpが処理される

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
takahiro0216
未経験からエンジニア転職を考え、独学中です。日々の学習内容の忘備録

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?