友情リンクの追加保存

31305 ワード

linkaddsave.php(phpページを保存)
 1 <?php

 2 include '../inc/db_mysqli.php';

 3 $ty = $_POST['ty'];

 4 if($ty=='Y'){

 5     //

 6     $stmt = $m->prepare('insert into hnsc_link(ltype,title,url,flag,atime) values(?,?,?,?,?)');

 7     $stmt->bind_param('ssssi',$ty,$title,$url,$flag,$atime);

 8     $title = $_POST['title'];

 9     $url = $_POST['url'];

10     $flag = $_POST['flag'];

11     $atime = time();

12     $stmt->execute();

13     $stmt->free_result();

14     $stmt->close();

15     $m->close();

16     header('location:linkmanager.php');

17 }else{

18        //      

19 }
db_mysqli.php
<?php

$host = 'localhost';

$user = 'root';

$pass = '';

$dbname = 'hnscdb';

$charset = 'utf8';

$m = new mysqli($host,$user,$pass,$dbname);

$m->set_charset($charset);



function mymd5($p,$c='webrx'){

    $s1 = md5($p.$c);

    $s2 = sha1($p.$c);

    $sok = substr($s1,0,6).substr($s2,0,6);

    $sok .= substr($s1,12,5).substr($s2,22,5);

    $sok .= substr($s1,22,5).substr($s2,32,5);

    return $sok;

}



function pager($tn,$currpage=1,$f='*',$pagesize=3,$w='1=1'){

    global $m;

    $stmt = $m->prepare("select count(*) from $tn where $w");

    $stmt->execute();

    $stmt->bind_result($recordcount);

    $stmt->fetch();

    $stmt->free_result();

    $stmt->close();

    

    $stmt = $m->prepare("select $f from $tn where $w limit ?,?");

    $pagecount = ceil($recordcount/$pagesize);

    $start = $currpage*$pagesize - $pagesize;

    $stmt->bind_param('ii',$start,$pagesize);

    $stmt->execute();

    $result = $stmt->get_result();

    $row = array();

    $row[] = $result->fetch_all( MYSQLI_NUM);

    $stmt->free_result();

    $stmt->close();



    $first = 1;

    $end = 10;

    $pages = '<div class="page">';

    if($currpage>=7){

        $first = $currpage-5;

        $end = $first+$end-1;

    }

    if($currpage>1){

        $prev = $currpage-1;

        if($first>1){

            $pages.="<a href=?p=1>  </a><a href=?p=$prev>   </a>";

        }else{

            $pages.="<a href=?p=$prev>   </a>";            

        }

    }

    for($i=$first;$i<=$end;$i++){

        if($i>$pagecount){

            break;    

        }

        if($i==$currpage){

            $pages.='<a class="checked">'.$i.'</a>';

            continue;    

        }

        $pages.="<a href=?p=$i>$i</a>";

    }

    if($currpage<$pagecount){

        $next = $currpage+1;

        $pages.="<a href=?p=$next>   </a>";        

    }

    if($end<$pagecount){

        $pages.="<a href=?p=$pagecount>  </a>";

    }

    $row[] = $pages.'</div>';

    $row[] = $pagesize;

    $row[] = $pagecount;

    $row[] = $recordcount;

    $row[] = $currpage;

    return $row;

}



function css1(){

    $css = <<<css

    <style>

    .page{font-size:12px;height:30px;padding:15px 0;clear:both;overflow:hidden;text-align:center;}

    .page a{text-decoration:none;line-height:25px;padding:0px 10px;display:inline-block;margin-right:5px;border:solid 1px #c8c7c7;}

    .page a:hover,.page a.checked{text-decoration:none;border:solid 1px #0086d6;background:#0091e3;color:#fff;}

    .page a:visited,.page a:link{color:#333;}

    .page a:active{color:#3B3B3B;}

    </style>

css;

    echo $css;        

}

linkadd.html(バックグラウンドページ表示)
 1 <!doctype html>

 2 <html>

 3 <head>

 4 <meta charset="utf-8">

 5 <title>webrx-title</title>

 6 <style>

 7 div#fff{display:none;}

 8 </style>

 9 </head>

10 

11 <body>

12 <h1>        </h1>

13 <form action="linkaddsave.php" method="post" enctype="multipart/form-data">

14   :

15 <label><input type="radio" name="ty" onclick="s(this)" value="Y" checked>    </label>

16 <label><input type="radio" name="ty" onclick="s(this)" value="N">    </label><br>

17   :<input type="text" maxlength="50" name="title" size="20"><br>

18 URL:<input type="text" maxlength="200" name="url" size="50"><br>

19 <div id="fff">  :<input type="file" name="img"><br></div>

20        :

21 <label><input type="radio" name="flag" value="Y" checked>  </label>

22 <label><input type="radio" name="flag" value="N">   </label><br>

23 <input type="submit" value="      ">

24 </form>

25 </body>

26 </html>

27 <script>

28 function s(i){

29     var obj = document.getElementById('fff');

30     if(i.value=='Y'){

31         obj.style.display = 'none';

32     }else{

33         obj.style.display = 'block';

34     }    

35 }

36 </script>

link.php
 1 <div class="links">

 2         <h1 class="linkstit">    <span class="eng">Links</span></h1>

 3         <div class="linkscon">

 4             <ul>

 5                 <?php

 6                 if($stmt=$m->prepare('select * from hnsc_link where flag=?')){

 7                     $stmt->bind_param('s',$flag);

 8                     $flag = 'Y';

 9                     $stmt->execute();

10                     $result = $stmt->get_result();

11                     $rows = $result->fetch_all(2);

12                     foreach($rows as $v){

13                         echo '<li><a href="'. $v[3] .'">'.$v[2].'</a></li>';

14                     }

15                 }else{

16                     echo '<li>     </li>';                        

17                 }

18                 

19                 ?>

20 

21             </ul>

22         </div>

23 </div>

index.php
 1 <?php

 2 include 'inc/db_mysqli.php';

 3 ?>

 4 <!DOCTYPE html>

 5 <html>

 6 <head>

 7 <meta charset="utf-8">

 8 <title>            、    、    </title>

 9 <meta name="keywords" content="    、    、              、      、hnshichang.com">

10 <meta name="description" content="    、    、              、      、hnshichang.com">

11 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">

12 <link href="css/style.css" rel="stylesheet">

13 <script src="js/j.js"></script>

14 </head>

15 

16 <body>

17 <?php include 'nav.html';?>

18 

19 <div class="container">

20     <div class="culture fl mr">

21         <h1 class="cultit">    <span class="eng">Culture</span></h1>

22         <div class="culcon0">

23             <p class="cullist"><span class="clbold">  </span>        ,</p>

24             <p class="cullist"><span class="clbold">  </span>        ,</p>

25             <p class="cullist"><span class="clbold">  </span>        ,</p>

26             <p class="cullist"><span class="clbold">  </span>         。</p>

27             <p class="cullist"><span class="clbold">    </span>      ,        ,        ,        </p>

28         </div>

29     </div>

30 

31 

32     <div class="intro fl">

33         <h1 class="introtit"><span class="titmore fr"><a href="#">  &gt;&gt;</a></span>    <span class="eng">Introduction</span></h1>

34         <div class="introcon">

35             <img src="images/abpic.jpg" class="intropic"/>               2014 6 ,    1000  ,              ,     :    、    、2  / 

36    、      、    、    、      。            ,            ,            。

37                        ,    ,    。

38         </div>

39     </div>

40 

41 

42 

43     <div class="culture fl ml">

44         <h1 class="cultit">    <span class="eng">Service</span></h1>

45         <div class="sercon">

46             <p class="serlist"><span class="clbold">  :</span>        (    )</p>

47             <p class="serlist"><span class="clbold">  :</span>0396-7636111</p>

48             <p class="serlist"><span class="clbold">  :</span>www.hnshichang.com</p>

49             <p class="serlist"><span class="clbold">  :</span>[email protected]</p>

50             <p class="chmes"><a href="#"></a></p>

51         </div>

52     </div>

53 

54     <h1 class="clear"></h1>

55 

56     <div class="culture fl mr">

57         <h1 class="cultit">    <span class="eng">Aptitude</span></h1>

58         <div class="apcon">

59             <img src="images/zizhi.jpg" />

60         </div>

61     </div>

62 

63 

64 

65     <div class="engineer fr">

66         <h1 class="engtit"><span class="titmore fr"><a href="#">  &gt;&gt;</a></span>    <span class="eng">Engineering</span></h1>

67         <div class="engcon">

68             <ul>

69                 <li><a href="#"><img src="images/gch.jpg" /></a></li>

70                 <li><a href="#"><img src="images/gch.jpg" /></a></li>

71                 <li><a href="#"><img src="images/gch.jpg" /></a></li>

72                 <li><a href="#"><img src="images/gch.jpg" /></a></li>

73             </ul>

74         </div>

75     </div>

76     <h1 class="clear"></h1>

77     <?php include 'link.php';?>  

78 </div>

79 <?php include 'footer.html';?>

80 </body>

81 </html>