216.73.216.34 TODAY : 207

PHP ์˜จ๋ผ์ธ ๊ฐ•์˜

 > 

PHP - ์ดˆ๊ธ‰

๐Ÿ“š PHP ์ดˆ๊ธ‰ - 7์ฃผ์ฐจ: HTML ํผ ์ฒ˜๋ฆฌ ๋ฐ GET/POST ๋ฐฉ์‹ - 01 HTML ํผ ์ƒ์„ฑ

๐Ÿ“š PHP ์ดˆ๊ธ‰ - 7์ฃผ์ฐจ: HTML ํผ ์ฒ˜๋ฆฌ ๋ฐ GET/POST ๋ฐฉ์‹ - 01 HTML ํผ ์ƒ์„ฑ
ํ‰์  10.0 ๋ผ์ด์„ผ์Šค free
์‚ฌ์šฉ์žํ‰์  10.0 ์šด์˜์ฒด์ œ
๋‹ค์šด๋กœ๋“œ 1 ํŒŒ์ผํฌ๊ธฐ 0
์ œ์ž‘์‚ฌ LUZENSOFT ๋“ฑ๋ก์ผ 2025-07-01 16:03:54
์กฐํšŒ์ˆ˜ 33
- ์„ค๋ช…

๐Ÿ“š PHP ์ดˆ๊ธ‰ - 7์ฃผ์ฐจ: HTML ํผ ์ฒ˜๋ฆฌ ๋ฐ GET/POST ๋ฐฉ์‹ - 01 HTML ํผ ์ƒ์„ฑ









HTML ํผ(Form)์ด๋ž€?


์›น ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉ์ž์˜ ์ž…๋ ฅ์„ ๋ฐ›๋Š” ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•์€ #HTML #ํผ(Form)์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

ํผ์€ ์‚ฌ์šฉ์ž๊ฐ€ ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜, ์˜ต์…˜์„ ์„ ํƒํ•˜๊ฑฐ๋‚˜, ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•˜๋Š” ๋“ฑ ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์›น ์„œ๋ฒ„๋กœ ์ „์†กํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” ์š”์†Œ์ž…๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๊ฐ€ ์›น์‚ฌ์ดํŠธ์—์„œ ํšŒ์›๊ฐ€์ž…์„ ํ•˜๊ฑฐ๋‚˜, ๋กœ๊ทธ์ธํ•˜๊ฑฐ๋‚˜, ๊ฒŒ์‹œ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ๋ณด๋Š” ๋Œ€๋ถ€๋ถ„์˜ ์ž…๋ ฅ ์ฐฝ๋“ค์ด ๋ฐ”๋กœ ์ด HTML ํผ์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค.

uploadImage



๊ธฐ๋ณธ์ ์ธ HTML ํผ ๊ตฌ์กฐ


HTML ํผ์€ <form> ํƒœ๊ทธ๋กœ ์‹œ์ž‘ํ•˜์—ฌ </form> ํƒœ๊ทธ๋กœ ๋๋‚ฉ๋‹ˆ๋‹ค. ์ด #<form> ํƒœ๊ทธ ์•ˆ์—๋Š” ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ์œ„ํ•œ ๋‹ค์–‘ํ•œ #์ž…๋ ฅ ์š”์†Œ(input elements)๋“ค์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.


uploadImage



<form> ํƒœ๊ทธ์˜ ์ฃผ์š” ์†์„ฑ


  • action: ํผ ๋ฐ์ดํ„ฐ๊ฐ€ ์ „์†ก๋  ์„œ๋ฒ„์˜ URL์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์ด ์†์„ฑ์ด ์—†์œผ๋ฉด ํ˜„์žฌ ํŽ˜์ด์ง€๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ์ „์†ก๋ฉ๋‹ˆ๋‹ค.

  • method: ํผ ๋ฐ์ดํ„ฐ๊ฐ€ ์ „์†ก๋  HTTP ๋ฐฉ์‹์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์ฃผ๋กœ #GET ๋˜๋Š” #POST ๋ฐฉ์‹์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.




์ฃผ์š” ์ž…๋ ฅ ์š”์†Œ (Input Elements)




  • <input type="text">: ํ•œ ์ค„์งœ๋ฆฌ ํ…์ŠคํŠธ ์ž…๋ ฅ์„ ๋ฐ›์Šต๋‹ˆ๋‹ค.

  • <input type="password">: ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ์„ ๋ฐ›์œผ๋ฉฐ, ์ž…๋ ฅ๋œ ๋‚ด์šฉ์€ ๋งˆ์Šคํ‚น ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

  • <input type="submit">: ํผ ๋ฐ์ดํ„ฐ๋ฅผ ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๋Š” ๋ฒ„ํŠผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

  • <textarea>: ์—ฌ๋Ÿฌ ์ค„์˜ ํ…์ŠคํŠธ ์ž…๋ ฅ์„ ๋ฐ›์Šต๋‹ˆ๋‹ค.

  • <select>: ๋“œ๋กญ๋‹ค์šด ๋ชฉ๋ก์„ ์ƒ์„ฑํ•˜์—ฌ ์—ฌ๋Ÿฌ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

  • <input type="radio">: ์—ฌ๋Ÿฌ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋งŒ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ผ๋””์˜ค ๋ฒ„ํŠผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

  • <input type="checkbox">: ์—ฌ๋Ÿฌ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜ ๋˜๋Š” ์—ฌ๋Ÿฌ ๊ฐœ๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์ฒดํฌ๋ฐ•์Šค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.






HTML ํผ ์ƒ์„ฑ ์˜ˆ์ œ




์•„๋ž˜๋Š” ๊ธฐ๋ณธ์ ์ธ ์‚ฌ์šฉ์ž ์ด๋ฆ„๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” #HTML ํผ ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

HTML

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML ํผ ์ƒ์„ฑ</title>
</head>
<body>
    <h1>๋กœ๊ทธ์ธ ํผ</h1>
    <form action="process.php" method="GET">
        <label for="username">์‚ฌ์šฉ์ž ์ด๋ฆ„:</label><br>
        <input type="text" id="username" name="username"><br><br>
        <label for="password">๋น„๋ฐ€๋ฒˆํ˜ธ:</label><br>
        <input type="password" id="password" name="password"><br><br>
        <input type="submit" value="๋กœ๊ทธ์ธ">
    </form>
</body>
</html>




์ฝ”๋“œ ์„ค๋ช…




  • <!DOCTYPE html>: HTML5 ๋ฌธ์„œ์ž„์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.

  • <html lang="ko">: ๋ฌธ์„œ์˜ ์–ธ์–ด๋ฅผ ํ•œ๊ตญ์–ด๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • <head>: ๋ฌธ์„œ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

    • <meta charset="UTF-8">: ๋ฌธ์ž ์ธ์ฝ”๋”ฉ์„ UTF-8๋กœ ์„ค์ •ํ•˜์—ฌ ํ•œ๊ธ€์ด ๊นจ์ง€์ง€ ์•Š๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

    • <meta name="viewport" content="width=device-width, initial-scale=1.0">: ๋ชจ๋ฐ”์ผ ๊ธฐ๊ธฐ์—์„œ ์›นํŽ˜์ด์ง€๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ณด์ด๋„๋ก ๋ทฐํฌํŠธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

    • <title>HTML ํผ ์ƒ์„ฑ</title>: ์›น ๋ธŒ๋ผ์šฐ์ € ํƒญ์— ํ‘œ์‹œ๋  ์ œ๋ชฉ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • <body>: ์›นํŽ˜์ด์ง€์˜ ์‹ค์ œ ๋‚ด์šฉ์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

    • <h1>๋กœ๊ทธ์ธ ํผ</h1>: ํŽ˜์ด์ง€์˜ ์ฃผ ์ œ๋ชฉ์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

    • <form action="process.php" method="GET">: ํผ์˜ ์‹œ์ž‘์„ ์•Œ๋ฆฌ๋ฉฐ, ๋ฐ์ดํ„ฐ๊ฐ€ process.php๋กœ #GET ๋ฐฉ์‹์œผ๋กœ ์ „์†ก๋  ๊ฒƒ์ž„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

    • <label for="username">์‚ฌ์šฉ์ž ์ด๋ฆ„:</label>: #<label> ํƒœ๊ทธ๋Š” ํผ ์š”์†Œ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ์ œ๊ณตํ•˜๋ฉฐ, for ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์–ด๋–ค ์ž…๋ ฅ ์š”์†Œ์™€ ์—ฐ๊ฒฐ๋˜๋Š”์ง€ ๋ช…์‹œํ•ฉ๋‹ˆ๋‹ค. (id๊ฐ€ "username"์ธ input๊ณผ ์—ฐ๊ฒฐ)

    • <input type="text" id="username" name="username">: #type="text"๋Š” ํ•œ ์ค„ ํ…์ŠคํŠธ ์ž…๋ ฅ์„ ์œ„ํ•œ ํ•„๋“œ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. #id๋Š” label๊ณผ์˜ ์—ฐ๊ฒฐ์„ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋ฉฐ, #name์€ ์„œ๋ฒ„๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ์ „์†ก๋  ๋•Œ ํ•ด๋‹น ๋ฐ์ดํ„ฐ์˜ ํ‚ค(key)๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

    • <br>: ์ค„ ๋ฐ”๊ฟˆ์„ ํ•ฉ๋‹ˆ๋‹ค.

    • <input type="password" id="password" name="password">: #type="password"๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ์„ ์œ„ํ•œ ํ•„๋“œ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

    • <input type="submit" value="๋กœ๊ทธ์ธ">: #type="submit"์€ ํผ์„ ์ œ์ถœํ•˜๋Š” ๋ฒ„ํŠผ์„ ์ƒ์„ฑํ•˜๋ฉฐ, #value ์†์„ฑ์€ ๋ฒ„ํŠผ์— ํ‘œ์‹œ๋  ํ…์ŠคํŠธ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.






๋‹ค์Œ ๋‹จ๊ณ„




์ด๋ ‡๊ฒŒ ์ƒ์„ฑ๋œ HTML ํผ์€ ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ๋ฐ›์„ ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ด ํผ์„ ํ†ตํ•ด ์ „์†ก๋œ ๋ฐ์ดํ„ฐ๊ฐ€ #PHP ์Šคํฌ๋ฆฝํŠธ์—์„œ #GET ๋ฐฉ์‹๊ณผ #POST ๋ฐฉ์‹์œผ๋กœ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌ๋˜๋Š”์ง€์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.