강의

멘토링

커뮤니티

Inflearn Community Q&A

dnjswnzzang0842's profile image
dnjswnzzang0842

asked

Create a web application by following along

Building a Web Application - Summary 8

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

Written on

·

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

Answer

This question is waiting for answers
Be the first to answer!
dnjswnzzang0842's profile image
dnjswnzzang0842

asked

Ask a question