먼저 사용자를
mysql>insert into user values('localhost','user',password('password'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N');
만들고
mysql>insert into db values('localhost','dbname','user','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
이렇게 만들고
create table info(id varchar(30);name varchar(30);tel varchar(30));
테이블을 생성하고나서
input.html파일을
<html>
<head>
<title>php 첫번째 테스트</title>
</head>
<body>
<center>
<form action="input.php3" method="post">
<h1>신규회원 가입신청서</h1>
<br><br>
<h3>개인정보를 입력하십시오</h3>
<table>
<tr>
<td> 아이디</td>
<td> <input type="text" name="id" size="30"></td>
</tr>
<tr>
<td> 이 름</td>
<td> <input type="text" name="id" size="30"></td>
</tr>
<tr>
<td> 전 화</td>
<td> <input type="text" name="id" size="30"></td>
</tr>
<tr>
<td colspan=2 align=center>
<input type="submit" value="신청"><input type="reset" value="지우기">
</td>
</tr>
</table>
</center>
</body>
</html>
----------------------------------------------------------------
input.php3 파일을
<?
if(!$name){
echo("<script>
windows.alert('이름을 넣으세요')
history.go(-1)
</script>
");
exit;
}
$connection = mysql_connect("localhost","myuser","myuser");
mysql_select_db("myuserdb",$connection);
$dbresult=mysql_quary("insert into info values('$id', $name', '$tel')", $connection);
if($dbresult=="")
{
echo("
<script>
window.alert('데이터 입력오류!!!')
history.go(-1)
</script>
");
exit;
}
?>
로 하고 웨브라우저에서 실행시키면
일단 에러는 안보입니다.
하지만 mysql에 가서
select * from info
하면 비어 있다고 나옵니다.
아시는 분 알려 주세요
|