php 获取用户IP与IE信息程序

 更新时间:2016年11月25日 16:03  点击:4519
php 获取用户IP与IE信息程序

function onlineip()
 {
  global $_SERVER;
  if(getenv('HTTP_CLIENT_IP'))
  {
   $onlineip = getenv('HTTP_CLIENT_IP');
  }
  elseif(getenv('HTTP_X_FORWARDED_FOR'))
  {
   list($onlineip) = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
  }
  elseif(getenv('REMOTE_ADDR'))
  {
   $onlineip = getenv('REMOTE_ADDR');
  }
  else
  {
   $onlineip = $_SERVER['REMOTE_ADDR'];
  }
  return $onlineip;
 }
 function imgdecode($string)
 {
  global $_SERVER;

  $key = md5(onlineip()."\t".$_SERVER['HTTP_USER_AGENT']);
  $coded = '';
  $string = base64_decode($string);
  $keylength = strlen($key);
  for($i = 0; $i < strlen($string); $i += $keylength)
  {
   $coded .= substr($string, $i, $keylength) ^ $key;
  }
  return $coded;
 }

php list 使用教程

list函数的作用list() 实际上是一种语言结构,不是函数... 提示和注释. 注释:该函数只用于数字索引的数组

我们来看个list实例

list($arr,$ar2) =array('aa','66');

list ($status, $host_count, $records)       = db_get_records($onadb, 'hosts', $where, "", 0);
list ($status, $dns_count, $records)        = db_get_records($onadb, 'dns', $where, "", 0);
list ($status, $interface_count, $records)  = db_get_records($onadb, 'interfaces', $where, "", 0);
list ($status, $domain_count, $records)     = db_get_records($onadb, 'domains', $where, "", 0);
list ($status, $subnet_count, $records)     = db_get_records($onadb, 'subnets', $where, "", 0);
list ($status, $pool_count, $records)       = db_get_records($onadb, 'dhcp_pools', $where, "", 0);
list ($status, $block_count, $records)      = db_get_records($onadb, 'blocks', $where, "", 0);
list ($status, $vlan_campus_count, $records) = db_get_records($onadb, 'vlan_campuses', $where, "", 0);
list ($status, $config_archive_count, $records) = db_get_records($onadb, 'configurations', $where, "", 0);

php 网站在线安装源码

<?php
 /*
 +-------------------------------------------
 |
 |   Technology of WeSpace Software
 |   ========================================
 |   Powered by WeSpace
 |   (c) 2006 wane.net
 |   F_Space Ver3.x
 |   ========================================
 |   Site: http://www.wesofts.com
 |
 +-------------------------------------------
 |   Autohr : wsfuyibing
 | Email : [email protected]
 | MSN  : [email protected]
 +-------------------------------------------
 */
 error_reporting(E_ERROR | E_WARNING | E_PARSE);
 set_magic_quotes_runtime(0);
 define('IN_www.111cn.net',true);
 define('IN_LICENSED',true);
 define('WANE_ROOT','../');
 $timestamp = time();
 $configfile = '../config.inc.php';
 /*
 +-------------------------------------------
 + Check PHP version
 +-------------------------------------------
 */
 if (@phpversion() < '4.1.0')
 {
     $_COOKIE = &$HTTP_COOKIE_VARS;
        $_SERVER = &$HTTP_SERVER_VARS;
        $_FILES = &$HTTP_POST_FILES;
        $_GET = &$HTTP_GET_VARS;
        $_POST = &$HTTP_POST_VARS;
 }
 /*
 +-------------------------------------------
 + Language
 +-------------------------------------------
 */
 $lang = in_array($_GET['lang'],array('gbk','big5','utf-8-gbk','utf-8-big5')) ? $_GET['lang'] : 'utf-8-gbk';
 $charset = substr($lang ,0,5);
 if (!file_exists('./'.$lang.'/language.php'))
 {
  exit('Can not load language file . ');
 }
 else
 {
  require_once './'.$lang.'/language.php';
 }
 /*
 +-------------------------------------------
 + Step
 +-------------------------------------------
 */
 $step  = file_exists('../upload/install.lock') ? '0' : ($_GET['step'] ? $_GET['step'] : '1');
 $steps = 16;
 $step = $step > $steps ? $steps : $step;
 /*
 +-------------------------------------------
 + Template
 +-------------------------------------------
 */
 $tpl_header  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
 $tpl_header .= '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
 $tpl_header .= '<head>'."\n";
 $tpl_header .= '<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" />'."\n";
 $tpl_header .= '<title>'.$tplang['title'].'</title>'."\n";
 $tpl_header .= '<link href="style.css" rel="stylesheet" type="text/css" />'."\n";
 $tpl_header .= '</head>'."\n";
 $tpl_header .= '<body>'."\n";
 $tpl_header .= '<table border="0" cellpadding="0" cellspacing="0" >'."\n\t".'<tr>'."\n\t\t".'<td class="headtitle">'.$tplang['title'].'</td>'."\n\t\t".'<td class="headsteps">'.($step > 1 ? $tplang['lang_'.$lang].' <br />' : '').$tplang['step_name'].': '.$tplang['step'.$step].'('.$tplang['step_cur'].$step.$tplang['step_unit'].'/'.$tplang['step_total'].$steps.$tplang['step_unit'].')</td>'."\n\t".'</tr>'."\n".'</table>'."\n";
 $tpl_footer  = '<table border="0" cellpadding="0" cellspacing="0" >'."\n\t".'<tr>'."\n\t\t".'<td class="footer">'.$tplang['footer'].'</td>'."\n\t".'</tr>'."\n".'</table>'."\n".'</body>'."\n";
 $tpl_footer .= '</html>';
 /*
 +-------------------------------------------
 + Start Install
 +-------------------------------------------
 */
 if (file_exists('../upload/install.lock'))
 {
  echo $tpl_header;
  ?>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <?=$tplang['step0_1']?>
     </td>
    </tr>
   </table>
  <?
  echo $tpl_footer;
 }
 elseif ($step == '1')
 {
  echo $tpl_header;
  ?>
  <div class="step1">
   <ol>
    <li>
     <a href="install.php?lang=gbk&amp;step=2"><?=$tplang['lang_gbk']?></a>
    </li>
    <li>
     <a href="install.php?lang=big5&amp;step=2"><?=$tplang['lang_big5']?></a>
    </li>
    <li>
     <a href="install.php?lang=utf-8-gbk&amp;step=2"><?=$tplang['lang_utf-8-gbk']?></a>
    </li>
    <li>
     <a href="install.php?lang=utf-8-big5&amp;step=2"><?=$tplang['lang_utf-8-big5']?></a>
    </li>
   </ol>
  </div>
  <?
  echo $tpl_footer;
 }
 elseif ($step == '2')
 {
  echo $tpl_header;
  ?>
   <div class="step2">
    <?=nl2br($tplang['license'])?>
   </div>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>"><?=$tplang['step_last']?></a>
        <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>"><?=$tplang['step_next']?></a>
     </td>
    </tr>
   </table>
  <?
  echo $tpl_footer;
 }
 elseif ($step == '3')
 {
  function filewrite()
  {
   return (file_exists('../config.inc.php') && is_writable('../config.inc.php')) ? '<span class="yes">'.$GLOBALS['tplang']['yes'].'</span>' : '<span class="no">'.$GLOBALS['tplang']['no'].'</span>';
  }
  function dirwrite($folder)
  {
   $filename = '../'.$folder.'/index.htm';
   $fp = @fopen($filename,'w+');
   if (!$fp)
   {
    return '<span class="no">'.$GLOBALS['tplang']['no'].'</span>';
   }
   else
   {
    @fwrite($fp,' &nbsp; ');
    fclose($fp);
    return '<span class="yes">'.$GLOBALS['tplang']['yes'].'</span>';
   }
  }
  echo $tpl_header;
 ?>
  <div class="step3">
   <ol>
    <li>
     <?=$tplang['step3_8']?> <?=filewrite()?>
    </li>
   </ol>
  </div>
  <div class="step3">
   <ol>
    <li style="list-style:none;padding-left:0px;color:#ff0000; "><?=$tplang['step3_0']?></li>
    <li>
     <?=$tplang['step3_1']?> <?=dirwrite('upload')?>
    </li>
    <li>
     <?=$tplang['step3_2']?> <?=dirwrite('upload/cards')?>
    </li>
    <li>
     <?=$tplang['step3_3']?> <?=dirwrite('upload/gifts')?>
    </li>
    <li>
     <?=$tplang['step3_4']?> <?=dirwrite('upload/group')?>
    </li>
    <li>
     <?=$tplang['step3_5']?> <?=dirwrite('wespacedata')?>
    </li>
    <li>
     <?=$tplang['step3_6']?> <?=dirwrite('wespacedata/cache')?>
    </li>
    <li>
     <?=$tplang['step3_7']?> <?=dirwrite('wespacedata/template')?>
    </li>
   </ol>
  </div>
  <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
   <tr>
    <td class="alignc">
       <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>"><?=$tplang['step_last']?></a>
       <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>"><?=$tplang['step_next']?></a>
    </td>
   </tr>
  </table>
 <?
  echo $tpl_footer;
 }
 elseif ($step == '4')
 {
  function filewrite()
  {
   return (file_exists('../config.inc.php') && is_writable('../config.inc.php')) ? '<span class="yes">'.$GLOBALS['tplang']['yes'].'</span>' : '<span class="no">'.$GLOBALS['tplang']['no'].'</span>';
  }
  if (!file_exists($configfile))
  {
   echo $tpl_header;
   ?>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <?=$tplang['step4_0']?>
     </td>
    </tr>
   </table>
   <?
   echo $tpl_footer;
  }
  else
  {
   require_once $configfile;
   echo $tpl_header;
   ?>
   <div class="step3">
    <ol>
     <li>
      <?=$tplang['step3_8']?> <?=filewrite()?>
     </li>
    </ol>
   </div>
   <form action="install.php?lang=<?=$lang?>&amp;step=5&amp;submit=1" method="post" name="wane_post">
   <table border="0" cellspacing="0" cellpadding="0" class="step4">
   <? foreach ($conf as $key=>$val){?>
              <tr>
                <td class="alignl"><?=$tplang['step4_'.$key]?></td>
                <td class="alignr"><input type="text" name="conf[<?=$key?>]" value="<?=$val?>" /></td>
              </tr>
   <? }?>
   <? foreach ($urlconf as $key=>$val){?>
              <tr>
                <td class="alignl"><?=$tplang['step4_'.$key]?></td>
                <td class="alignr"><input type="text" name="urlconf[<?=$key?>]" value="<?=$val?>" /></td>
              </tr>
   <? }?>
              <tr>
                <td colspan="2" class="alignc">
     <input type="hidden" name="configsubmit" value="1" />
     <input type="button" name="LastStep" value="<?=$tplang['step_last']?>" onclick="location='install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>'" />
     <input type="submit" name="Submit" value="<?=$tplang['step_confsave']?>" />
     <input type="button" name="Skipit" value="<?=$tplang['step_skip']?>" onclick="location='install.php?lang=<?=$lang?>&amp;step=<?=$step+2?>'" />
    </td>
              </tr>
            </table>
   </form>
   <?
   echo $tpl_footer;
  }
 }
 elseif ($step == '5')
 {
  require_once WANE_ROOT.'install/query/5.php';
  header("location:install.php?lang={$lang}&step=6");
 }
 elseif ($step == '6')
 {
  if (!file_exists($configfile))
  {
   echo $tpl_header;
   ?>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <?=$tplang['step4_0']?>
     </td>
    </tr>
   </table>
   <?
   echo $tpl_footer;
  }
  else
  {
   require_once $configfile;
   $conn = @mysql_connect($conf['dbserver'],$conf['dbuser'],$conf['dbpass']);
   echo $tpl_header;
   if (!$conn)
   {
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
         <?=$tplang['step6_1_0']?>
      </td>
     </tr>
    </table>
    <?
   }
   else
   {
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
         <?=$tplang['step6_1_1']?>
      </td>
     </tr>
    </table>
    <?
    $sels = @mysql_select_db($conf['dbname'],$conn);
    if (!$sels)
    {
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step6_2_0']?>
       </td>
      </tr>
     </table>
     <?
    }
    else
    {
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step6_2_1']?>
       </td>
      </tr>
     </table>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-2?>"><?=$tplang['step_last']?></a>
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>"><?=$tplang['step_next']?></a>
       </td>
      </tr>
     </table>
     <?
    }
   }
   echo $tpl_footer;
  }
 }
 elseif ($step == '7')
 {
  if (!file_exists($configfile))
  {
   echo $tpl_header;
   ?>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <?=$tplang['step4_0']?>
     </td>
    </tr>
   </table>
   <?
   echo $tpl_footer;
  }
  else
  {
   echo $tpl_header;
   $sqlfile = './sql/struct.php';
   if (!file_exists($sqlfile))
   {
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
         <?=$tplang['step7_0_0']?> (<?=$sqlfile?>)
      </td>
     </tr>
    </table>
    <?
   }
   else
   {
    $fp = @fopen($sqlfile,'r');
    if (!$fp)
    {
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step7_0_1']?> (<?=$sqlfile?>)
       </td>
      </tr>
     </table>
     <?
    }
    else
    {
     require_once WANE_ROOT.'install/query/7.php';
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step7_1']?>
       </td>
      </tr>
     </table>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>"><?=$tplang['step_last']?></a>
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>"><?=$tplang['step_next']?></a>
       </td>
      </tr>
     </table>
     <?
    }
   }
   echo $tpl_footer;
  }
 }
 elseif ($step >= '8' && $step <= '14')
 {
  if (!file_exists($configfile))
  {
   echo $tpl_header;
   ?>
   <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
    <tr>
     <td class="alignc">
        <?=$tplang['step4_0']?>
     </td>
    </tr>
   </table>
   <?
   echo $tpl_footer;
  }
  else
  {
   echo $tpl_header;
   $sqlfile = './'.$lang.'/data'.$step.'.php';
   if (!file_exists($sqlfile))
   {
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
         <?=$tplang['step7_0_0']?> (<?=$sqlfile?>)
      </td>
     </tr>
    </table>
    <?
   }
   else
   {
    $fp = @fopen($sqlfile,'r');
    if (!$fp)
    {
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step7_0_1']?> (<?=$sqlfile?>)
       </td>
      </tr>
     </table>
     <?
    }
    else
    {
     require_once WANE_ROOT.'install/query/8-14.php';
     ?>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <?=$tplang['step14_1']?>
       </td>
      </tr>
     </table>
     <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
      <tr>
       <td class="alignc">
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>"><?=$tplang['step_last']?></a>
          <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>"><?=$tplang['step_next']?></a>
       </td>
      </tr>
     </table>
     <?
    }
   }
   echo $tpl_footer;
  }
 }
 elseif ($step == '15')
 {
  echo $tpl_header;
  ?>
   <form action="install.php?lang=<?=$lang?>&amp;step=<?=$step+1?>&amp;submit=1" method="post" name="wane_post">
   <table border="0" cellspacing="0" cellpadding="0" class="step15">
              <tr>
                <td class="alignl"><?=$tplang['step15_u']?></td>
                <td class="alignl"><input type="text" name="username" value="<?=$val?>" /></td>
              </tr>
              <tr>
                <td class="alignl"><?=$tplang['step15_p']?></td>
                <td class="alignl"><input type="text" name="password" value="<?=$val?>" /></td>
              </tr>
              <tr>
                <td class="alignl"><?=$tplang['step15_s']?></td>
                <td class="alignl">
    <input name="sex" type="radio" value="1" checked /> <?=$tplang['step15_s1']?>
                <input name="sex" type="radio" value="2" /> <?=$tplang['step15_s2']?>
    </td>
              </tr>
              <tr>
                <td class="alignl"><?=$tplang['step15_e']?></td>
                <td class="alignl"><input type="text" name="email" value="<?=$val?>" /></td>
              </tr>
              <tr>
                <td colspan="2" class="alignc">
     <input type="hidden" name="configsubmit" value="1" />
     <input type="submit" name="Submit" value="<?=$tplang['step_confsave']?>" />
    </td>
              </tr>
            </table>
   </form>
  <?
  echo $tpl_footer;
 }
 else
 {
  $configsubmit = trim($_POST['configsubmit']);
  if ($step == '16' && $configsubmit)
  {
   $magic = @get_magic_quotes_gpc();
   function cutempty($varchar)
   {
    global $magic,$_POST;
    $varchar = $magic ? stripslashes($_POST[$varchar]) : $_POST[$varchar];
    return addslashes(htmlspecialchars(str_replace(array(" ","\n","\t","\r"),array("","","",""),$varchar)));
   }
   $username = substr(cutempty('username'),0,15);
   $password = cutempty('password');
   $email = cutempty('email');
   $sex = cutempty('sex');
   if (!$username || !$password || !$email || !$sex)
   {
    echo $tpl_header;
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
       <br />
       <?=$tplang['step15_1_0']?><br /><br />
       <a href="install.php?lang=<?=$lang?>&amp;step=<?=$step-1?>"><?=$tplang['step_last']?></a>
       <br /> <br />  
      </td>
     </tr>
    </table>
    <?
    echo $tpl_footer;
   }
   else
   {
    require_once WANE_ROOT.'install/query/16.php';
    echo $tpl_header;
    ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
       <br />
       <?=$tplang['step16_1']?><br /><br />
       <a href="../"><?=$tplang['step16_2']?></a>
       <br /> <br />    
      </td>
     </tr>
    </table>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
       <br />
       <?=$tplang['step15_u']?>:<?=$username?> <br />
       <?=$tplang['step15_p']?>:<?=$password?> <br />
       <?=$tplang['step15_s']?>:<?=$sex=='1' ? $tplang['step15_s1'] : $tplang['step15_s2']?> <br />
       <?=$tplang['step15_e']?>:<?=$email?> <br /><br />
      </td>
     </tr>
    </table>
    <?
    echo $tpl_footer;
   }
  }
  else
  {
   echo $tpl_header;
   ?>
    <table border="0" cellspacing="0" cellpadding="0" class="stepchose">
     <tr>
      <td class="alignc">
       <br />
       <?=$tplang['step16_1']?><br /><br />
       <a href="../"><?=$tplang['step16_2']?></a>
       <br /> <br />    
      </td>
     </tr>
    </table>
   <?
   echo $tpl_footer;
  }
 }
?>

php简单用户登陆程序代码

这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。

<center>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <form name="form1" method="post" action="login_cl.php">
    <table width="500" height="241" border="0" cellpadding="0" cellspacing="0">
      <tr align="center">
        <td colspan="2" bgcolor="#999999">会员登陆界面 (login.php)|<a href="index.php">返回</a> </td>
      </tr>
      <tr bgcolor="#CCCCCC">
        <td width="137" align="center">用户:</td>
        <td width="363"><input name="yd631_name" type="text" id="yd631_name"></td>
      </tr>
      <tr bgcolor="#D9D9D9">
        <td align="center">密码:</td>
        <td><input name="yd631_pws" type="password" id="yd631_pws"></td>
      </tr>
      <tr align="center" bgcolor="#CCCCCC">
        <td colspan="2"><input type="submit" name="Submit" value="提交">   
          <input type="reset" name="submit" value="重置">
   
          </td>
      </tr>
    </table>
  </form>
  <p>&nbsp;</p>
  </center>

登陆的php处理代码

include("config.php");
?>
<?php
if(empty($_POST["yd631_name"])){
echo ("<script type='text/javascript'> alert('用户名怎么能是空的呢!');history.go(-1);</script>");
}
if(empty($_POST["yd631_pws"])){
echo ("<script type='text/javascript'> alert('密码也不能是空的!');history.go(-1);</script>");
}
$yd631_name= $_POST["yd631_name"]; //用户名已经记录了
$yd631_pws= $_POST["yd631_pws"]; //密码已经记录了
$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db);
$sql="select * from $sqltable where yd631_name='$yd631_name' and yd631_pws='$yd631_pws'";
$result=mysql_fetch_array(mysql_query($sql));
if(!$result){
echo ("<script type='text/javascript'> alert('用户名或密码不正确!');history.go(-1);</script>");
mysql_close();
exit;
}
if($result["yd631_pass"]=="no"){
 //验证会员是不是被审核通过了
echo ("<script type='text/javascript'> alert('您还没有被审核呢!');history.go(-1);</script>");
}
session_start();
$_SESSION["name"]="$yd631_name";
echo "<script>location.href='yd631.php';</script>";
?>

config文件。

<?php
//常规参数设置

$servername="localhost";  //主机名
$sqlservername="root"; //mysql数据库用户名
$sqlserverpws="yd631"; //mysql数据库密码

$sqlname="yd631_user"; //数据库名
$sqltable="yd631_users"; //username表名


$admin_name="yd631";  //管理员用户名
$admin_pws="yd631";   //管理员密码
?>

简单的php 用户注册程序[全套]

<?php
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>yd631_php_user会员管理实例</title>
</head>

<body><center>
  <form name="form1" method="post" action="reg_cl.php"><table width="68%" height="304"  border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr align="center" bgcolor="#CCCCCC">
      <td colspan="2">注册(reg.php)||<a href="index.php">返回</a></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td width="29%" align="right">用户名:</td>
      <td width="71%" align="left"><input name="yd631_name" type="text" id="yd631_name"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">密码:</td>
      <td align="left"><input name="yd631_pws" type="password" id="yd631_pws"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">性别:</td>
      <td align="left"><input name="yd631_sex" type="radio" value="男" checked>
        男
           
          <input type="radio" name="yd631_sex" value="女"> 
        女</td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">年龄:</td>
      <td align="left"><input name="yd631_age" type="text" id="yd631_age" size="10" maxlength="4"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">电话:</td>
      <td align="left"><input name="yd631_call" type="text" id="yd631_call"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">邮件:</td>
      <td align="left"><input name="yd631_email" type="text" id="yd631_email"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">地址:</td>
      <td align="left"><input name="yd631_address" type="text" id="yd631_address" size="40"></td>
    </tr>
    <tr align="center" bgcolor="#CCCCCC">
      <td colspan="2"><input type="submit" name="Submit" value="提交">  
        <input type="reset" name="Submit" value="重置"></td>
    </tr>
  </table>
  </form>
</center>

</body>
</html>

注册php处理页面

<?php
//注册处理页面
//www.yd631.com
//技术D.JOY
function checkmail($nmail){   /// 验证电子邮件地址
 if(ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+",$nmail))
  return true;
 else
  return false;
}

include("config.php"); //参数页面提取过来

if(empty($_POST["yd631_name"])){
echo ("<script type='text/javascript'> alert('用户名不能是空的');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_pws"])){
echo ("<script type='text/javascript'> alert('密码为空了吧');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_sex"])){
echo ("<script type='text/javascript'> alert('性别呢');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_age"])){
echo ("<script type='text/javascript'> alert('年龄不能为空');history.go(-1);</script>");
exit;
}
if(!is_numeric($_POST["yd631_age"])){
echo ("<script type='text/javascript'> alert('年龄要是数字的');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_call"])){
echo ("<script type='text/javascript'> alert('电话不能为空');history.go(-1);</script>");
exit;
}
if(!is_numeric($_POST["yd631_call"])){
echo ("<script type='text/javascript'> alert('电话要是数字的');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_email"])){
echo ("<script type='text/javascript'> alert('邮箱不能为空');history.go(-1);</script>");
exit;
}
if($_POST["yd631_email"]!=""){

  if(!checkmail($_POST["yd631_email"])) {
 echo ("<script type='text/javascript'> alert('不对了,邮箱格式');history.go(-1);</script>");
 exit;
  }
}

if(empty($_POST["yd631_address"])){
echo ("<script type='text/javascript'> alert('地址不能为空');history.go(-1);</script>");
exit;
}

$yd631_name=$_POST["yd631_name"];
$yd631_pws=$_POST["yd631_pws"];
$yd631_sex=$_POST["yd631_sex"];
$yd631_age=$_POST["yd631_age"];
$yd631_call=$_POST["yd631_call"];
$yd631_email=$_POST["yd631_email"];
$yd631_address=$_POST["yd631_address"];
$yd631_time=date("Y-m-d");
$yd631_pass="no";

$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db) ;
$sql="select * from $sqltable where yd631_name='$yd631_name'";
$result=mysql_fetch_row(mysql_query($sql));

if($result){
echo ("<script type='text/javascript'> alert('用户名在,你就不能注册这个名字');history.go(-1);</script>");

}
else{
$sql="insert into $sqltable(yd631_name,yd631_pws,yd631_sex,yd631_age,yd631_call,yd631_email,yd631_address,yd631_time,yd631_pass) values('$yd631_name','$yd631_pws','$yd631_sex','$yd631_age','$yd631_call','$yd631_email','$yd631_address','$yd631_time','$yd631_pass') ";
mysql_query($sql);

echo ("<script type='text/javascript'> alert('添加成功');location.href='index.php';</script>");
}
?>

mysql数据库

--
-- 表的结构 `yd631_users`
--

CREATE TABLE `yd631_users` (
  `yd631_id` int(10) NOT NULL auto_increment,
  `yd631_name` varchar(10) default NULL,
  `yd631_pws` varchar(10) default NULL,
  `yd631_sex` varchar(4) default NULL,
  `yd631_age` varchar(4) default NULL,
  `yd631_call` varchar(15) default NULL,
  `yd631_email` varchar(20) default NULL,
  `yd631_address` text,
  `yd631_pass` varchar(4) default NULL,
  `yd631_time` date default NULL,
  PRIMARY KEY  (`yd631_id`)
) ;

相关文章

  • php 获取用户IP与IE信息程序

    php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
  • php获取一个文件夹的mtime的程序

    php获取一个文件夹的mtime的程序了,这个就是时间问题了,对于这个问题我们来看小编整理的几个例子,具体的操作例子如下所示。 php很容易获取到一个文件夹的mtime,可以...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • Jquery 获取指定标签的对象及属性的设置与移除

    1、先讲讲JQuery的概念,JQuery首先是由一个 America 的叫什么 John Resig的人创建的,后来又很多的JS高手也加入了这个团队。其实 JQuery是一个JavaScript的类库,这个类库集合了很多功能方法,利用类库你可以用简单的一些代...2014-05-31
  • php根据用户语言跳转相应网页

    当来访者浏览器语言是中文就进入中文版面,国外的用户默认浏览器不是中文的就跳转英文页面。 <&#63;php $lan = substr(&#8194;$HTTP_ACCEPT_LANGUAGE,0,5); if ($lan == "zh-cn") print("<meta http-equiv='refresh' c...2015-11-08
  • 如何获取网站icon有哪些可行的方法

    获取网站icon,常用最简单的方法就是通过website/favicon.ico来获取,不过由于很多网站都是在页面里面设置favicon,所以此方法很多情况都不可用。 更好的办法是通过google提供的服务来实现:http://www.google.com/s2/favi...2014-06-07
  • jquery获取div距离窗口和父级dv的距离示例

    jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 复制代码 代码如下: *{ mar...2013-10-13
  • jquery如何获取元素的滚动条高度等实现代码

    主要功能:获取浏览器显示区域(可视区域)的高度 : $(window).height(); 获取浏览器显示区域(可视区域)的宽度 :$(window).width(); 获取页面的文档高度 $(document).height(); 获取页面的文档宽度 :$(document).width();...2015-10-21
  • php获取汉字拼音首字母的方法

    现实中我们经常看到这样的说明,排名不分先后,按姓名首字母进行排序。这是中国人大多数使用的排序方法。那么在php程序中该如何操作呢?下面就分享一下在php程序中获取汉字拼音的首字母的方法,在网上搜到的大多数是有问题的...2015-10-23
  • DOM XPATH获取img src值的query

    复制代码 代码如下:$nodes = @$xpath->query("//*[@id='main_pr'][email protected]");$prurl = $nodes->item(0)->nodeValue;...2013-10-04
  • php ajax注册验证用户名是否存在代码

    这是注册程序是一款当用户输入完用户名是,就会自动去数据库中查询用户要注册的用户名是否己经被注册了,如果是返回提示否则提示可以注册。 conn.php文件 代...2016-11-25
  • PHP 如何获取二维数组中某个key的集合

    本文为代码分享,也是在工作中看到一些“大牛”的代码,做做分享。 具体是这样的,如下一个二维数组,是从库中读取出来的。 代码清单: 复制代码 代码如下: $user = array( 0 => array( 'id' => 1, 'name' => '张三', 'ema...2014-06-07
  • php如何获取文件的扩展名

    网上也有很多类似的方法,不过都存在这样那样的不严谨的问题,本文就不一一分析了,这里只给出最正确的利用php 获取文件扩展名(文件后缀名)的方法。 function get_extension($filename){ return pathinfo($filename,PATHIN...2015-10-30
  • jquery获取tagName再进行判断

    如果是为了取到tagName后再进行判断,那直接用下面的代码会更方便: $(element).is('input') 如果是要取到标签用作到别的地方,可以使用一下代码: $(element)[0].tagName 或: $(element).get(0).tagName...2014-05-31
  • php有效防止同一用户多次登录

    【问题描述】:同一用户在同一时间多次登录如果不能检测出来,是危险的。因为,你无法知道是否有其他用户在登录你的账户。如何禁止同一用户多次登录呢? 【解决方案】 (1) 每次登录,身份认证成功后,重新产生一个session_id。 s...2015-11-24
  • js检测用户输入密码强度

    一个用Javascript检测用户输入密码强度的效果代码,以下代码主要是从以下四个方面检测用户输入的密码的强度的,有兴趣的朋友可以自己添加或修改成自己想要的形式! 1. 如果输入的密码位数少于5位,那么就判定为弱。 2. 如果...2015-10-23
  • php 获取数组长度几种方法

    在php中获取数组长度方法很简单,php为我们提供了两个函数可以计算一维数组长度,如count,sizeof都可以直接统计数组长度哦,下面我们来看几个实例吧。 php如何获取数组...2016-11-25
  • MySQL验证用户权限的方法

    知识归纳因为MySQL是使用User和Host两个字段来确定用户身份的,这样就带来一个问题,就是一个客户端到底属于哪个host。 如果一个客户端同时匹配几个Host,对用户的确定将按照下面的优先级来排 基本观点越精确的匹配越优先...2015-11-08
  • 用python获取txt文件中关键字的数量

    这篇文章主要介绍了如何用python获取txt文件中关键字的数量,帮助大家更好的理解和使用python,感兴趣的朋友可以了解下...2020-12-24
  • mysql误删root用户恢复方法

    装完数据库清理一些默认账号的时候不小心把root删除了,flush privileges 之后的新 root 忘了grant任何权限,查看mysqld选项里面有个 &#8722;&#8722;skip-grant-tables复制代码 代码如下: #/usr/libexec/mysqld --verbos...2015-03-15