묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
가르쳐 주세요!!! ㅜ.ㅜ
2002.08.30 11:11
CREATE TABLE `pendant` (`usernumber` MEDIUMINT(8) NOT NULL AUTO_INCREMENT primary key, `useid` VARCHAR(8) BINARY NOT NULL, `userpassword` VARCHAR(20) BINARY NOT NULL, `username` VARCHAR(30) NOT NULL, `usercountry` VARCHAR(40) NOT NULL, `usermail` VARCHAR(50) NOT NULL, `userprofile` VARCHAR(100) NOT NULL, `registerdate` DATE NOT NULL, `lastaccesstime` TIMESTAMP(14)) COMMENT = 'pendant'
이렇게 테이블을 만들었습니다.
그리고 php로
$query = "INSERT INTO user VALUE(NULL , '$userid', password('$userpassword'),'$username','$usermail','$userprofile',curdate(),NULL)";
이렇게 했는데 에러가 나오더군요....
왜그러죠?
<?php
include "common_db.inc";
$link_id = db_connect();
mysql_select_db("metalnation");
mysql_close($link_id);
function in_use($userid){
global $user_tablename;
$query = "SELECT userid FROM $user_tablename WHERE userid='userid'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) return 0;
else return 1;
}
function register_form()
{
global $userid,$username,$usercountry,$usermail,$userprofile,$country_array;
global $PHP_SELF;
?>
<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td class=r2>
이 회원가입 폼은 목걸이 주문시 좀더 편하게 하기위해 제작 한것입니다.<br>
이름과 주소는 실명으로 입력해 주세요! 아직 많이 부족하여 주소찾기는 넣지 못했습니다. ㅡ.ㅡ<br><BR>
</td>
</tr>
<tr>
<td align=center>
<form method="post" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="action" value="register">
<table border=0 cellspacing=0 cellpadding=4 align=center>
<tr>
<td align=right valign=middle>
<img src="gif/id.gif">
</td>
<td align=left valign=middle>
<input type="text" name="userid" value="<?php echo $userid ?>" size="8" maxlength="8">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass.gif">
</td>
<td align=left valign=middle>
<input type="PASSWORD" name="userpassword" size="15">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass2.gif">
</td>
<td align=left valign=middle>
<input type="PASSWORD" name="userpassword2" size="15">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/name.gif">
</td>
<td align=left valign=middle>
<input type="text" name="username" value="<?php echo $username ?>" size="20" >
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/type.gif">
</td>
<td align=left valign=middle>
<select name="usercountry">
<option selected>닌자 스타</option>
<option>울 프</option>
</select>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/mail.gif">
</td>
<td align=left valign=middle>
<input type="text" name="usermail" value="<?php echo $usermail ?>" size="20" >
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/address.gif">
</td>
<td align=left valign=middle>
<input type="text" name="userprofile" value="<?php echo $userprofile ?>" size="30">
</td>
</tr>
<tr>
<td colspan=2><bR>
<table width=100% boder=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td align=center>
<input type=image src="gif/confirm.gif" alt="회원가입" border=0>
</td>
<td align=center>
<input type=image src="gif/cancel.gif" alt="취 소" border=0 onclick="history.back(-1);">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
}
function create_account() {
global $userid,$username,$userpassword,$userpassword2,$usermail,$usercountry,$userprofile;
global $default_dbname,$user_tablename;
if(empty($userid)) error_message("사용하실 ID를 입력해 주세요!");
if(empty($userpassword)) error_message("비밀번호를 입력해야 합니다.");
if(strlen($userpassword) < 6) error_message("비밀번호가 짧습니다.");
if(empty($userpassword2)) error_message("확인을 위해 비밀번호를 두번 입력해야 합니다.");
if(empty($username)) error_message("이름을 입력하지 않으셨습니다.");
if(empty($usermail)) error_message("이메일 주소가 입력되지 않았습니다.");
if(empty($userprofile)) error_message("주소를 입력하지 않으셨군요.");
if($userpassword != $userpassword2)
error_message("입력한 비밀번호가 서로 맞지 않습니다.");
$link_id = db_connect($default_dbname);
if(in_use($userid))
error_message("$userid 는 이미 사용중입니다. 다른 ID를 선택해 주세요.");
$query = "INSERT INTO user VALUE(NULL , '$userid', password('$userpassword'),'$username','$usermail','$userprofile',curdate(),NULL)";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
$usernumber = mysql_insert_id($link_id);
html_header();
?>
<table width=100% boder=0 cellspacing=0 cellpadding=0 center>
<tr>
<td class=r2>
<?php echo $username ?> 님, 회원 등록을 해주셔서 감사합니다.<br><BR>
</td>
</tr>
<tr>
<td>
<table width=100% boder=0 cellspacing=0 cellpadding=0 center>
<tr>
<td align=right>
<img src="gif/id.gif">
</td>
<td align=left valign=middle>
<?php echo $userid ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass.gif">
</td>
<td align=left valign=middle>
<?php echo $userpassword ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/name.gif">
</td>
<td align=left valign=middle>
<?php echo $username ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/type.gif">
</td>
<td align=left valign=middle>
<?php echo $usercountry ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/mail.gif">
</td>
<td align=left valign=middle>
<?php echo $usermail ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/address.gif">
</td>
<td align=left valign=middle>
<?php echo $userprofile ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
html_footer();
}
switch($action) {
case "register":create_account();
break;
default:html_header(); register_form(); html_footer();
break;
}
?>
이렇게 테이블을 만들었습니다.
그리고 php로
$query = "INSERT INTO user VALUE(NULL , '$userid', password('$userpassword'),'$username','$usermail','$userprofile',curdate(),NULL)";
이렇게 했는데 에러가 나오더군요....
왜그러죠?
<?php
include "common_db.inc";
$link_id = db_connect();
mysql_select_db("metalnation");
mysql_close($link_id);
function in_use($userid){
global $user_tablename;
$query = "SELECT userid FROM $user_tablename WHERE userid='userid'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) return 0;
else return 1;
}
function register_form()
{
global $userid,$username,$usercountry,$usermail,$userprofile,$country_array;
global $PHP_SELF;
?>
<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td class=r2>
이 회원가입 폼은 목걸이 주문시 좀더 편하게 하기위해 제작 한것입니다.<br>
이름과 주소는 실명으로 입력해 주세요! 아직 많이 부족하여 주소찾기는 넣지 못했습니다. ㅡ.ㅡ<br><BR>
</td>
</tr>
<tr>
<td align=center>
<form method="post" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="action" value="register">
<table border=0 cellspacing=0 cellpadding=4 align=center>
<tr>
<td align=right valign=middle>
<img src="gif/id.gif">
</td>
<td align=left valign=middle>
<input type="text" name="userid" value="<?php echo $userid ?>" size="8" maxlength="8">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass.gif">
</td>
<td align=left valign=middle>
<input type="PASSWORD" name="userpassword" size="15">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass2.gif">
</td>
<td align=left valign=middle>
<input type="PASSWORD" name="userpassword2" size="15">
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/name.gif">
</td>
<td align=left valign=middle>
<input type="text" name="username" value="<?php echo $username ?>" size="20" >
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/type.gif">
</td>
<td align=left valign=middle>
<select name="usercountry">
<option selected>닌자 스타</option>
<option>울 프</option>
</select>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/mail.gif">
</td>
<td align=left valign=middle>
<input type="text" name="usermail" value="<?php echo $usermail ?>" size="20" >
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/address.gif">
</td>
<td align=left valign=middle>
<input type="text" name="userprofile" value="<?php echo $userprofile ?>" size="30">
</td>
</tr>
<tr>
<td colspan=2><bR>
<table width=100% boder=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td align=center>
<input type=image src="gif/confirm.gif" alt="회원가입" border=0>
</td>
<td align=center>
<input type=image src="gif/cancel.gif" alt="취 소" border=0 onclick="history.back(-1);">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
}
function create_account() {
global $userid,$username,$userpassword,$userpassword2,$usermail,$usercountry,$userprofile;
global $default_dbname,$user_tablename;
if(empty($userid)) error_message("사용하실 ID를 입력해 주세요!");
if(empty($userpassword)) error_message("비밀번호를 입력해야 합니다.");
if(strlen($userpassword) < 6) error_message("비밀번호가 짧습니다.");
if(empty($userpassword2)) error_message("확인을 위해 비밀번호를 두번 입력해야 합니다.");
if(empty($username)) error_message("이름을 입력하지 않으셨습니다.");
if(empty($usermail)) error_message("이메일 주소가 입력되지 않았습니다.");
if(empty($userprofile)) error_message("주소를 입력하지 않으셨군요.");
if($userpassword != $userpassword2)
error_message("입력한 비밀번호가 서로 맞지 않습니다.");
$link_id = db_connect($default_dbname);
if(in_use($userid))
error_message("$userid 는 이미 사용중입니다. 다른 ID를 선택해 주세요.");
$query = "INSERT INTO user VALUE(NULL , '$userid', password('$userpassword'),'$username','$usermail','$userprofile',curdate(),NULL)";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
$usernumber = mysql_insert_id($link_id);
html_header();
?>
<table width=100% boder=0 cellspacing=0 cellpadding=0 center>
<tr>
<td class=r2>
<?php echo $username ?> 님, 회원 등록을 해주셔서 감사합니다.<br><BR>
</td>
</tr>
<tr>
<td>
<table width=100% boder=0 cellspacing=0 cellpadding=0 center>
<tr>
<td align=right>
<img src="gif/id.gif">
</td>
<td align=left valign=middle>
<?php echo $userid ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/pass.gif">
</td>
<td align=left valign=middle>
<?php echo $userpassword ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/name.gif">
</td>
<td align=left valign=middle>
<?php echo $username ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/type.gif">
</td>
<td align=left valign=middle>
<?php echo $usercountry ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/mail.gif">
</td>
<td align=left valign=middle>
<?php echo $usermail ?>
</td>
</tr>
<tr>
<td align=right valign=middle>
<img src="gif/address.gif">
</td>
<td align=left valign=middle>
<?php echo $userprofile ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
html_footer();
}
switch($action) {
case "register":create_account();
break;
default:html_header(); register_form(); html_footer();
break;
}
?>
바로 넣는거라면.. VALUE가 아니라.. VALUES 로 해줘야 합니다..~!