PageRenderTime 66ms CodeModel.GetById 42ms RepoModel.GetById 1ms app.codeStats 0ms

/bookmanage/resetdb.php

https://bitbucket.org/ufotalent/classes_in_zju
PHP | 31 lines | 27 code | 4 blank | 0 comment | 1 complexity | 9208efeb7202d7b65fcc5ce63196e5b8 MD5 | raw file
  1. <?php
  2. $chosen="General";
  3. include "side.php";
  4. echo ' <div id="main-content"> <!-- Main Content Section with everything -->';
  5. $con=mysql_connect("localhost","root","root");
  6. mysql_query("use bookmanage");
  7. $command="select * from administrator where aid='".$_REQUEST["aid"]."' and passwd='".$_REQUEST["passwd"]."'";
  8. $result=mysql_query($command);
  9. $row=mysql_fetch_array($result);
  10. if ($row) {
  11. mysql_query("drop table books");
  12. mysql_query("create table books (bookid char(20),type char(20),name char(50),publisher char(50),publish_year integer,author char(50),price integer,total_storage integer,storage integer,primary key (bookid))");
  13. mysql_query("drop table administrator");
  14. mysql_query("create table administrator (aid char(30),passwd char(30), name char(30),contact char(30),primary key (aid))");
  15. mysql_query("insert into administrator values('admin','admin','Ufotalent','15068154598')");
  16. mysql_query("drop table card");
  17. mysql_query("create table card (cid char(30),name char(30),station char(30),type char(30),primary key (cid))");
  18. mysql_query("drop table record");
  19. mysql_query("create table record (cid char(30),bookid char(20),aid char(30), bdate date, rdate date, foreign key (cid) references card, foreign key (aid) references administrator, foreign key (bookid) references books)");
  20. echo mysql_error();
  21. echo "reset";
  22. }
  23. else
  24. echo "authentication error";
  25. echo '</div>';
  26. echo "</html>"
  27. ?>