[sql] yardim!!

Konu Yazar

ermanasya

New Member
Kalemi Kırıldı!
Haz
634
3
Arkadaslar 2moons server kuruyorum... Uyelık alınırken sorun yasıyorum web dosyalarımda hata var odbc aldım ama yıne ıse yaramıyorum kaynak kodlar asagıda duzenlersenız sevınırım... Ben sıze db tablelerındekı gerekli table ısımlerını vereyım

user_no = rasgele id numarası kimlik no gıbı bısey..

user_id = ıd

user_pwd = pw

user_mail = yazılan mail adresi

user_answer = cevap

user_question = soru


KAYNAK KODLAR register.html

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Õ˺Å×¢²á</title>
<style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
.style5 {	FONT-WEIGHT: bold; COLOR: #999999
}
.STYLE13 {FONT-WEIGHT: bold; COLOR: #FFFFFF; }
.STYLE14 {color: #FFFFFF}
.STYLE15 {
	font-size: 30px;
	font-weight: bold;
	color: #990033;
}
-->
</style></head>

<body><center>
<TABLE height=20 cellSpacing=0 cellPadding=0 width=461 border=0 bgcolor="#000000">
<TBODY>
              <TR>
                <TD width=10 rowspan="2" vAlign=top><IMG height=15 
                  src="images/type1.gif" width=2></TD>
                <TD><div align="center">
                  <p class="STYLE15">¼«ÏŞÌôÕ½×¢²áÕ˺Å</p>
                </div></TD>
              </TR>
              <TR>
                <TD><p class="STYLE6">
                  <?=$errorStr ?><br>
</p>
                </TD>
              </TR>
  </TBODY></TABLE>

<table width="778" height="330" 
                                border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
  <form method="post" action="register.php">
    <input type="hidden" name="step2" value="1" />
    <center>
      <tbody>
        <tr>
          <td height="37" class="STYLE13"><div align="left"><span class="STYLE1">Ñ¡ÔñÓÎÏ··ÖÇø:</span></div></td>
          <td class="STYLE13"><p>
            <label>
              <input name="ZoneGroup" type="radio" value="zone1" checked="checked" />
              <span class="STYLE1"> ¼«ÏŞÌôÕ½</span></label>
            <span class="STYLE1">
              <label></label>
              <br />
              <label></label>
            </span></p></td>
        </tr>
        <tr height="40">
          <td width="130" class="style5 STYLE14">&nbsp;&nbsp;
              <div align="left">*Óû§Ãû </div></td>
          <td width="210"><div align="left">
            <input name="username" type="text" value="" />
          </div></td>
          <td width="438" class="STYLE13"><div align="left">ÓÉÓ¢ÎÄ×Öĸ¡¢Êı×Ö×é³É£¬³¤¶ÈÔÚ6-12¸ö×ֽڼ䡣(ÌØÊâ×Ö·û²»¿ÉÓÃ)¡£</div></td>
        </tr>
        <tr>
          <td height="40" class="STYLE13">&nbsp;&nbsp;
              <div align="left">*ÃÜÂë</div></td>
          <td height="40"><div align="left">
            <input name="password1" type="password" value="" />
          </div></td>
          <td height="40" class="STYLE13"><div align="left">ÓÉ6-12¸öÊı×ÖºÍ×Öĸ×é³É¡£(ÌØÊâ×Ö·û²»¿ÉÓÃ)¡£ </div></td>
        </tr>
        <tr>
          <td height="40" class="STYLE13">&nbsp;&nbsp;
              <div align="left">*ÖØ¸´ÃÜÂë</div></td>
          <td height="40"><div align="left">
            <input name="password2" type="password" value="" />
          </div></td>
          <td height="40" class="STYLE13"><div align="left">ÇëÖØ¸´ÉÏÃæµÄÃÜÂë¡£</div></td>
        </tr>
        <tr>
          <td height="40" class="STYLE13">&nbsp;&nbsp;
              <div align="left">*ÃÜÂëÎÊÌâ</div></td>
          <td height="40"><div align="left">
            <input name="question" type="text" value="" />
          </div></td>
          <td height="40" class="STYLE13"><div align="left">³¤¶ÈÔÚ10-20¸ö×ֽڼ䡣</div></td>
        </tr>
        <tr>
          <td height="40" class="STYLE13">&nbsp;&nbsp;
              <div align="left">*ÃÜÂë´ğ°¸</div></td>
          <td height="40"><div align="left">
            <input name="answer" type="text" value="" />
          </div></td>
          <td height="40" class="STYLE13"><div align="left">³¤¶ÈÔÚ10-20¸ö×ֽڼ䡣</div></td>
        </tr>
        <tr>
          <td height="40" class="STYLE13">&nbsp;&nbsp;
              <div align="left">*E-mail</div></td>
          <td height="40"><div align="left">
            <input name="mail" type="text" value="" />
          </div></td>
          <td height="40" class="STYLE13"><div align="left">ÌîÈëÕæÊµÓĞЧµÄEmailµØÖ·</div></td>
        </tr>
        <tr>
          <td><div align="left"></div></td>
          <td colspan="2" class="STYLE13"><div align="left">&nbsp;</div></td>
        </tr>
        <tr>
        <tr>
          <td><div align="left"></div></td>
          <td colspan="2" class="STYLE13"><div align="left">×¢Ò⣬ÃÜÂëÕһؾùĞèÒª±¾Ò³ËùÌî×ÊÁÏ(Èç³öÏÖ×¢²áû·´Ó³Çë°ÑÃÜÂëÎÊÌâ+Ó¢ÎÄÊı×Ö×¢²á)</div></td>
        </tr>
        <tr>
          <td><div align="left"></div></td>
          <td colspan="2" class="STYLE13"><div align="left">&nbsp;</div></td>
        </tr>
        <tr>
          <td colspan="3" height="10"><div align="left">
            <center>
              <input name="submit" type="submit"  value="Ìá½»" />
            </center>
          </div></td>
        </tr>
      </tbody>
    </center>
  </form>
</table>
</center>
</body>
</html>

KAYNAK KODU - register.php

PHP:
<?php

require_once "config.inc.php";

if(isset($_SESSION[step2]) && isset($_POST[step2])) {
//ÌáÈ¡µÄ×îºóÒ»²½
$errorStr = formStep3();
if($errorStr!=null){
require_once('register.html');
}else{
require_once('success.html');
$suc=$success;
unset($_SESSION[step2], $_SESSION[step1]);
}}
else {
//×¢²áµÄµÚ¶?²½
require_once('register.html');
$_SESSION[step2] = 1; }


//Å?¶ÏÓû§Ìá½»µÄ±íµ¥µÄÊy¾YµÄ ׼ȷ?Ô ºÍ ±£´æÌá½»Êy¾Y µÄº¯Êy
function formStep3(){
$errors = array();
$errorStr = null;
//²éѯÓû§ÃûÊÇ·ñ´æÔÚ
$strSql="select * from Tbl_user where user_id='$_POST[username]'";
if ($_POST[ZoneGroup]=="zone1") { 
$account_odbc = odbc_connect('account','royalorder','royalorder'); 
} elseif ($_POST[ZoneGroup]=="zone2") {
$account_odbc = odbc_connect('account2','royalorder','royalorder');
} else { 
die ("<p><b>·ÖÇøÑ¡Ôñ´íÎó!</b></p>");
} 
$user_result=odbc_do($account_odbc,$strSql);
$result_query=odbc_fetch_row($user_result);
if (odbc_result($user_result,1)!= "") $errors[] = "¸ÃÃû³ÆÒѾ*±»Õ¼Óã¬ÇëÖØ?ÂÊäÈë";
//ÑéÖ¤Óû§ÃûÊÇ·ñ¹æ·¶
if(!preg_match("/^[0-9a-zA-Z]{6,12}$/i", $_POST[username])) $errors[]="Ö»ÄÜÓÃÓ¢ÎÄ´ó?¡?´×ÖĸÊy×ÖµÄ×éºÏ×÷ΪÓû§Ãû";
//ÑéÖ¤Óû§Ãû³¤¶È
if(strlen($_POST[username])<6) $errors[] = "Óû§ÃûµÄ³¤¶È²»ÄÜ?¡ÓÚ6λ";
if(strlen($_POST[username])>12) $errors[]= "Óû§ÃûµÄ³¤¶È²»Äܳ¬¹y12λ";
//ÑéÖ¤ÃÜÂëÊÇ·ñ¹æ·¶
if(!preg_match("/^[0-9a-zA-Z]{6,12}$/i", $_POST[password1])) $errors[]="Ö»ÄÜÓÃÓ¢ÎÄ´ó?¡?´×ÖĸÊy×ÖµÄ×éºÏ×÷ΪÃÜÂë";
if(preg_match("/^[0-9]{6,12}$/i",$_POST[password1])) $errors[]="²»¿ÉʹÓô¿Êy×Ö×÷ΪÃÜÂë";
//ÑéÖ¤Óû§ÃûºÍÃÜÂëÊÇ·ñÏàͬ
if($_POST[username]==$_POST[password1]) $errors[]= "ÕʺźÍÃÜÂë²»ÄÜÏàͬ";
//ÑéÖ¤ÃÜÂ볤¶È
if(strlen($_POST[password1])<6) $errors[] = "ÃÜÂëµÄ³¤¶È²»ÄÜ?¡ÓÚ6λ";
if(strlen($_POST[password1])>12) $errors[] = "ÃÜÂ볤¶È²»ÄÜ´óÓÚ12λ";
//ÑéÖ¤ÃÜÂëÒ»ÖÂ?Ô
if($_POST[password2]!=$_POST[password1]) $errors[] = "ÊäÈëµÄÃÜÂë²»Ò»ÖÂ";
//ÑéÖ¤ÕÒ»ØÃÜÂëÎÊÌâ´?°¸³¤¶È
if(strlen($_POST[question])>20) $errors[] = "ÕÒ»ØÃÜÂëÎÊÌâ´óÓÚ20룬Çë·µ»ØÖØ?ÂÊäÈë";
if(strlen($_POST[question])<10) $errors[] = "ÕÒ»ØÃÜÂëÎÊÌâ?¡ÓÚ10룬Çë·µ»ØÖØ?ÂÊäÈë";
if(strlen($_POST[answer])>20) $errors[] = "ÕÒ»ØÃÜÂë´?°¸´óÓÚ20룬Çë·µ»ØÖØ?ÂÊäÈë";
if(strlen($_POST[answer])<10) $errors[] = "ÕÒ»ØÃÜÂë´?°¸?¡ÓÚ10룬Çë·µ»ØÖØ?ÂÊäÈë";
//ÑéÖ¤Óû§emailÕyÈ·?Ô
if(!preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i",$_POST[mail])) $errors[]="EmailµØÖ·²»ÕyÈ·£¬ÇëÖØ?ÂÊäÈëÕyÈ·µÄEmailµØÖ·";


//´íÎó?ÅÏ¢Êä³ö
if(sizeof($errors)>0){
$errorStr .= "<br><font>";
$errorStr .= "?ÅÏ¢ÊäÈë´íÎó£º";
foreach($errors as $error)
$errorStr .= "<li>$error</li>";
$errorStr .= "</font><br><br>";
}else{

//¼ÓÃÜÃÜÂë
$passwd_user=md5($_POST[password1]);
//»ñÈ¡user_no
$dk_time=strftime("%y%m%d%H%M%S");
list($usec1, $sec1) = explode(" ",microtime());
$dk_user_no=$dk_time.substr($usec1,2,2);
//Óû§×¢²áÓï¾ä
$dk_account_query="insert into user_profile(user_no,user_id,user_pwd,resident_no, user_type,login_flag,login_tag,ipt_time,login_time ,logout_time,user_ip_addr,server_id) values('$dk_user_no','$_POST[username]','$passwd_user','801011000000','1','0','Y','01/01/2006 00:00:00',null,null,null,'000')";
//Óû§×ÊÁϱ£´æ
$dk_account_query2="insert into Tbl_user(user_no,user_id,user_pwd,user_mail,user_a nswer,user_question) values('$dk_user_no','$_POST[username]','$_POST[password1]','$_POST[mail]','$_POST[answer]','$_POST[question]')";
//Ö´??Óû§×¢²áºÍ×ÊÁϱ£´æÓï¾ä
$dk_account_result1=odbc_do($account_odbc,$dk_acco unt_query);
$dk_account_result2=odbc_do($account_odbc,$dk_acco unt_query2);
odbc_close($account_odbc);



}
//·µ»Ø´íÎóÏûÏ¢µ½Ò³Ãæ
return $errorStr;
}

?>

config.inc.php

PHP:
<?php

//¿ªÊ¼session
session_start();

//ÉèÖò»½øĞб¾µØ»º´æ
header('Expires: '.date('D,d M Y H:i:s',mktime(0,0,0,1,1,2000)).' GMT');
header('Last-Modified:'.gmdate('D,d M Y H:i:s').' GMT');
header('Cache-control: private, no-cache,must-revalidate');
header('Pragma: no-cache');

$db_name="account";
$db_host="localhost";
$db_user="royalorder";
$db_pwd="royalorder";
?>
 
Geri
Üst Alt