반응형
<html>
<head>
<title> SQL 테스트(php.2) </title>
</head>
<body>

<?php
include ("1.php");
$sql="select * from member";
$result = mysql_query($sql,$connect);

while ($row = mysql_fetch_row($result))
{
 echo 'ID:  '.$row[0].'  ';
 echo 'PW:  '.$row[1].'  ';
 echo 'NAME:  '.$row[2].'  ';
 echo 'E-mail:  '.$row[3].'  ';
 echo '<br>';
}
?> 

</body>
</html> ​
//php.1
<?

$DbMachine ="localhost";
$DbUser ="kjuju02";
$DbPasswd = "k5276283^";

$connect =mysql_connect ($DbMAchine,$DbUser,$DbPasswd);

mysql_select_db("kjuju02",$connect) or die ("데이터 베이스를 잘못 선택했습니다.");
mysql_set_charset ("utf-8");

?>
//insert
<?
  $id=$_POST['id'];
  $pw=$_POST['pw'];
  $name=$_POST['name'];
  $E_mail=$_POST['E_mail'];
  echo $id;
  echo "<br>";
  echo $pw;
  echo "<br>";
  echo $name;
  echo "<br>";
  echo $E_mail;
  echo "<br>";

  include("1.php");
  $sql="INSERT INTO member(id, pw, name, E_mail) VALUES('$id', '$pw;', '$name;','E_mail;')";
  $result=mysql_query($sql, $connect);

  $sql="SELECT * FROM member";
  $result=mysql_query($sql, $connect);
  while($row=mysql_fetch_row($result))
  {
	echo 'ID: '.$row[0].'  ';
	echo 'PW: '.$row[1].'  ';
    echo 'NAME: '.$row[2].'  ';
    echo 'E_mail: '.$row[3].'  ';
    echo '<br>';
  }
?>
	<form action="in.php" method="post" name="insert">
	I&nbsp;&nbsp;D:<input type="text" name="id" value=""><BR>
	P&nbsp;&nbsp;W:<input type="text" name="pw" value=""><BR>
	NAME:<input type="text" name="name" value=""><BR>
	E-mail:<input type="text" name="E_mail" value=""><BR>

	<input type="submit" name="run" value="실행">
//delete
<?
  $id=$_POST['id'];
  $pw=$_POST['pw'];
  $name=$_POST['name'];
  $E_mail=$_POST['E_mail'];
  echo $id;
  echo "<br>";
  echo $pw;
  echo "<br>";
  echo $name;
  echo "<br>";
  echo $E_mail;
  echo "<br>";

  include("1.php");
  $sql="DELETE FROM member WHERE id='$id'";
  $result=mysql_query($sql, $connect);
  $sql="SELECT * FROM member";
  $result=mysql_query($sql, $connect);
  echo "<table border=1>";
  while($row=mysql_fetch_row($result))
  {
  	echo "<tr>";
	echo "<td>";echo 'ID: '; echo "</td>";
	echo "<td>";echo $row[0]; echo "</td>";
	echo "<td>";echo 'PW: '; echo "</td>";
	echo "<td>";echo $row[1]; echo "</td>";
	echo "<td>";echo 'NAME: '; echo "</td>";
	echo "<td>";echo $row[2]; echo "</td>";
	echo "<td>";echo 'mail: '; echo "</td>";
	echo "<td>";echo $row[3]; echo "</td>";
	echo "</tr>";
  }
  echo "</table>";
?>

	<form action="de.php" method="post" name="insert">
	I&nbsp;&nbsp;D:<input type="text" name="id" value=""><BR>
	P&nbsp;&nbsp;W:<input type="text" name="pw" value=""><BR>
	NAME:<input type="text" name="name" value=""><BR>
	E-mail:<input type="text" name="E_mail" value=""><BR>

	<input type="submit" name="run" value="실행">
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

Array2  (0) 2019.08.26
Array  (0) 2019.08.26
table  (0) 2019.08.26
케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26

+ Recent posts