0

プログラマーの皆さん、

少し問題があり、オンラインで正しい答えを見つけることができません。

基本的に私がする必要があるのは、ユーザーがコンテンツをテキスト ボックスに挿入し、チェック ボックスを選択することです。どちらのチェック ボックスが選択されていても、テキスト ボックスの内容が挿入されるテーブルとなります。**両方のチェック ボックスをオンにして、ユーザーが 2 つの差分テーブルにアップロードできるようにします。いいえと尋ねる前に、完全な差分テーブルでなければならない差分行にアップロードすることはできません。

よくわからない場合はお知らせください。事前に感謝します

HTML CODE:
<body class="login">
   <div class="wrapper">
      <h1><a href="index.php"><img src="img/logo-big.png" alt="" class='retina-ready' width="59" height="49">FLAT</a></h1>
      <div class="login-body">
         <form action="db_pre_panel.php" name="login" class='form-validate' id="test" method="post">
            <div class="control-group">
               <div class="email controls">
                  <h3>TEST</h3>
                  <input type="text" name="content" maxlength="500" placeholder="Content" />
               </div>
            </div>
            <div class="control-group">
               <input type="checkbox" name="Ck_1" /> <label>Ck_1</label>//If selected then INSERT content into tbl_connect
               <input type="checkbox" name="Ck_2" /> <label>Ck_2</label>//If selected then INSERT content into tbl_share
            </div>
            <div class="submit">
               <input type="submit" value="Simplicity" />
            </div>

PHP CODE:
<?php
    //Define Content, Post & Share
    $content=$_POST['content'];
    $post=$_POST['ck_1'];
    $share=$_POST['ck_2'];

    //Insert into the db    
    $sql_post="INSERT INTO $tbl_connect (wall) VALUES ('$connect', '$post')";
    $sql_share="INSERT INTO $tbl_share (wall) VALUES ('$connect', '$share')";

    //Make sure it insert into db   
    $result_post = mysql_query($sql_post);
    $result_share = mysql_query($sql_share);

    if($result_post){
       header("location:alert.php");
    }else{
       header("location:error.html");
    }

    if($result_share){
       header("location:http://www.google.com");
    }else{
       header("location:error.html");
    }
?>
4

1 に答える 1

1

シンプルにしてください:

   //Define Content, Post & Share
   $content = $_POST['content'];  // you should sanitize this to prevent SQL injection

   if ( !empty($_POST['ck_1']) ) {
      $sql_post = "INSERT INTO `tbl_connect` (wall) VALUES ('$connect')";  // if you have more than one value, then you need to specify more than one column...
   }

   if ( !empty($_POST['ck_2']) ) {
      $sql_share = "INSERT INTO `tbl_share` (wall) VALUES ('$connect')";
   }
于 2013-05-30T04:29:08.067 に答える