강의

멘토링

커뮤니티

Inflearn コミュニティ Q&A

dnjswnzzang0842 のプロフィール画像
dnjswnzzang0842

投稿した質問数

模倣しながら学ぶ Web アプリケーションの作成

Webアプリケーションの作成 - クリーンアップ8

새로운 name 을 입력할때마다 이름값이 안들어가네요..

作成

·

196

0

if($result->num_rows > 0){ // 존재한다면 user.id을 알아낸다.

  $row = mysqli_fetch_assoc($result);

  $user_id = $row['id'];

}

else{ // 존재하지 않는다면 저자를 user 추가 후 id를 알아낸다

  $sql = "INSERT INTO user (id, name) VALUES (NULL, '{$author}');";

  $result = mysqli_query($conn, $sql);

  $user_id = mysqli_insert_id($conn);

}

$title = mysqli_real_escape_string($conn, $_POST['title']);

$description = mysqli_real_escape_string($conn, $_POST['description']);

$sql = "INSERT INTO

          `topic`

          (`id`, `title`, `description`, `author`, `created`)

          VALUES (NULL, '{$title}', '{$description}', '{$user_id}', now());";

          mysqli_query($conn, $sql);

          header('Location: index.php');

author 값이 계속 0이 들어갑니다 새로운값을 입력할때

HTML/CSSphp

回答

回答を待っている質問です
最初の回答を残してください!
dnjswnzzang0842 のプロフィール画像
dnjswnzzang0842

投稿した質問数

質問する