Advertisement
adrianconeac

test

Dec 9th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. //Oracle
  2.  
  3.  
  4.  
  5. //CREARE TABELA IN CONSOLA
  6.  
  7. CREATE TABLE candidati(cnp char(13) PRIMARY KEY,
  8. nume varchar(30),
  9. prenume varchar(30),
  10. adresa varchar(30),
  11. media_bac number(4,2),
  12. media_multianuala_mate number(4,2));
  13.  
  14. INSERT INTO candidati VALUES ('1234566785432','Bogdan','Sebastian','Str.Borsecului',8,9);
  15.  
  16. //INSERARE HTML
  17.  
  18. <html>
  19. <body>
  20. <form action="http://localhost/inserare.php" method="POST">
  21. <table align="center" border="4" bgcolor="blue">
  22. <tr>
  23. <td>CNP:</td>
  24. <td><input type="text" name="cnp_form"></td>
  25. </tr>
  26. <tr>
  27. <td>NUME:</td>
  28. <td><input type="text" name="nume_form"></td>
  29. </tr>
  30. <tr>
  31. <td>PRENUME:</td>
  32. <td><input type="text" name="prenume_form"></td>
  33. </tr>
  34. <tr>
  35. <td>ADRESA:</td>
  36. <td><input type="text" name="adresa_form"></td>
  37. </tr>
  38. <tr>
  39. <td>MEDIA BAC:</td>
  40. <td><input type="text" name="media_bac_form"></td>
  41. </tr>
  42. <tr>
  43. <td>MEDIA MULTIANUALA:</td>
  44. <td><input type="text" name="media_multianuala_mate_form"></td>
  45. </tr>
  46. <tr>
  47. <td><input type="submit" value ="adaugare"></td>
  48. </tr>
  49. </table>
  50. </form>
  51. </body>
  52. </html>
  53.  
  54.  
  55.  
  56. //INSERARE PHP
  57. <?php
  58.  
  59. $cnp=$_POST['cnp_form'];
  60. $nume=$_POST['nume_form'];
  61. $prenume=$_POST['prenume_form'];
  62. $adresa=$_POST['adresa_form'];
  63. $media_bac=$_POST['media_bac_form'];
  64. $media_multianuala_mate=$_POST['media_multianuala_mate_form'];
  65.  
  66. $connection=OCILogon("system","student","XE");
  67. $stmt=OCI_Parse($connection,"select count(*) from candidati where cnp='$cnp'");
  68. OCIExecute($stmt);
  69. if(OCIFetch($stmt))
  70. {
  71. $stmt1=OCI_Parse($connection,"insert into candidati values('$cnp','$nume','$prenume','$adresa','$media_bac','$media_multianuala_mate')");
  72. OCIExecute($stmt1);
  73. OCIFreeStatement($stmt1);
  74. header("location:afisare.php");
  75. }
  76. else
  77. {
  78. echo "Persoana nu se poate adauga";
  79. }
  80. OCIFreeStatement($stmt);
  81. OCILogoff($connection);
  82. ?>
  83.  
  84.  
  85. //DELETE HTML
  86. <html>
  87. <body>
  88. <form action="http://localhost/delete.php" method="POST">
  89. <table border="4" align ="center">
  90. <tr>
  91. <td>CNP:</td>
  92. <td><input type="text" name="cnp_form"> </td>
  93. </tr>
  94. <tr>
  95. <td><input type="submit" value ="stegere"></td>
  96. </tr>
  97. </table>
  98. </form>
  99. </body>
  100. </html>
  101.  
  102. //DELETE PHP
  103.  
  104. <?php
  105.  
  106. echo $cnpp=$_POST['cnp_form'];
  107.  
  108. $connection=OCILogon("system","student","XE");
  109. $stmt=OCI_Parse($connection,"select * from candidati where cnp='$cnpp'");
  110. OCIExecute($stmt);
  111.  
  112. if(OCI_Fetch_row($stmt))
  113. {
  114. $stmt1=OCI_Parse($connection,"delete from candidati where cnp='$cnpp'");
  115. OCIExecute($stmt1);
  116. OCIFreeStatement($stmt1);
  117. echo"Persoana a fost stearsa";
  118. header("location:afisare.php");
  119.  
  120. }
  121. else
  122. {
  123. echo"Persoana cautata nu se gaseste in baza de date";
  124. }
  125.  
  126. OCIFreeStatement($stmt);
  127. OCILogoff($connection);
  128.  
  129. ?>
  130.  
  131. //MENIU HTML
  132. <html>
  133. <head>
  134. <title>INDEX!!</title>
  135. </head>
  136. <body>
  137.  
  138. <a href="http://localhost/afisare.php>Afisare</a><br>
  139. <a href="http://localhost/delete.html>Delete</a><br>
  140.  
  141. </body>
  142. </html>
  143.  
  144. //AFISARE PHP
  145.  
  146. <?php
  147.  
  148. $connection=OCILogon("system","student","XE");
  149. $stmt=OCIParse($connection,"select * from candidati");
  150. OCIExecute($stmt);
  151.  
  152. echo "<table border='4' align='center'>";
  153. echo "<tr>";
  154. echo "<td>cnp</td>";
  155. echo "<td>nume</td>";
  156. echo "<td>prenume</td>";
  157. echo "<td>adresa</td>";
  158. echo "<td>media_bac</td>";
  159. echo "<td>media_multianula_mate</td>";
  160. echo "</tr>";
  161.  
  162. while(OCI_Fetch_row($stmt))
  163. {
  164. $cnp=OCIResult($stmt,"CNP");
  165. $nume=OCIResult($stmt,"NUME");
  166. $prenume=OCIResult($stmt,"PRENUME");
  167. $adresa=OCIResult($stmt,"ADRESA");
  168. $media_bac=OCIResult($stmt,"MEDIA_BAC");
  169. $media_multianuala_mate=OCIResult($stmt,"MEDIA_MULTIANUALA_MATE");
  170. echo "<tr>";
  171. echo "<th>$cnp</th>";
  172. echo "<th>$nume</th>";
  173. echo "<th>$prenume</th>";
  174. echo "<th>$adresa</th>";
  175. echo "<th>$media_bac</th>";
  176. echo "<th>$media_multianuala_mate</th>";
  177. echo "</tr>";
  178. }
  179. echo "</table>";
  180.  
  181. $stmt2=OCI_Parse($connection,"select min(media_bac) from candidati");
  182. OCIExecute($stmt2);
  183. while($sir=OCI_Fetch_row($stmt2))
  184. {
  185. echo "Cea mai mica medie la bacalaureat este : ".$sir[0]."!";
  186. }
  187.  
  188. $stmt3=OCI_Parse($connection,"select min(media_multianuala_mate) from candidati");
  189. OCIExecute($stmt3);
  190. while($sir=OCI_Fetch_row($stmt3))
  191. {
  192. echo "Cea mai mica medie multianuala este : ".$sir[0]."!";
  193. }
  194. OCIFreeStatement($stmt);
  195. OCILogoff($connection);
  196. ?>
  197.  
  198. //CAUTARE HTML
  199.  
  200. <html>
  201. <body>
  202. <form action="http://localhost/cautare.php" method="POST">
  203. <table border='4' align='center'>
  204. <tr>
  205. <td>CNP:</td>
  206. <td><input type="text" name="cn_form"></td>
  207. </tr>
  208. <tr>
  209. <td><input type="submit" value="CAUTA"></td>
  210. </tr>
  211. </table>
  212. </form>
  213. </body>
  214. </html>
  215.  
  216. //CAUTARE PHP
  217.  
  218. <?php
  219.  
  220. $cnnp=$_POST['cn_form'];
  221.  
  222. $connection=OCILogon("system","student","XE");
  223. $stmt=OCI_Parse($connection,"select * from candidati where cnp='$cnnp'");
  224. OCIExecute($stmt);
  225.  
  226. if(OCIFetch($stmt))
  227. {
  228. $cnp=OCIResult($stmt,"CNP");
  229. $nume=OCIResult($stmt,"NUME");
  230. $prenume=OCIResult($stmt,"PRENUME");
  231. $adresa=OCIResult($stmt,"ADRESA");
  232. $media_bac=OCIResult($stmt,"MEDIA_BAC");
  233. $media_multianuala_mate=OCIResult($stmt,"MEDIA_MULTIANUALA_MATE");
  234. echo "<tr>";
  235. echo "<th>$cnp</th>";
  236. echo "<th>$nume</th>";
  237. echo "<th>$prenume</th>";
  238. echo "<th>$adresa</th>";
  239. echo "<th>$media_bac</th>";
  240. echo "<th>$media_multianuala_mate</th>";
  241. echo "</tr>";
  242. }
  243. else
  244. {
  245. echo "Persoana cautata nu exista";
  246. }
  247. OCIFreeStatement($stmt);
  248. OCILogoff($connection);
  249. ?>
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256. //MYSQL
  257.  
  258. //CREARE BAZA DE DATE
  259.  
  260. create database admitere;
  261. use admitere;
  262.  
  263.  
  264.  
  265. CREATE TABLE candidati(id int PRIMARY KEY auto_increment,
  266. nume varchar(30),
  267. prenume varchar(30),
  268. adresa varchar(30),
  269. media_bac double,
  270. media_multianuala_mate double);
  271.  
  272.  
  273.  
  274. //INTRODUCERE DIN CONSOLA
  275.  
  276. INSERT INTO candidati(nume,prenume,adresa,media_bac,media_multianuala_mate) VALUES
  277. ('Bogdan','Sebastian','Str.Lalelei',8.56,9),('Diaconu','Paula','Str.Frunzei',6.55,7);
  278.  
  279.  
  280.  
  281.  
  282. //MENIU HTML
  283. <html>
  284. <head>
  285. <title>INDEX!!</title>
  286. </head>
  287. <body>
  288. <a href="http://localhost/afisare.php">Afisare</a><br>
  289. <a href="http://localhost/inserare.html">Adaugare</a><br>
  290. </body>
  291. </html>
  292.  
  293. //INSERARE PHP
  294.  
  295. <?php
  296.  
  297. mysql_connect("localhost","root","") or die("nu se poate connecta");
  298. mysql_select_db("admitere") or die("nu se gaseste baza de date");
  299. echo "<br><br>";
  300.  
  301. echo $id=$_POST['id_form'];
  302. echo $nume=$_POST['nume_form'];
  303. echo $prenume=$_POST['prenume_form'];
  304. echo $adresa=$_POST['adresa_form'];
  305. echo $media_bac=$_POST['media_bac_form'];
  306. echo $media_multianuala_mate=$_POST['media_multianuala_mate_form'];
  307.  
  308. $query=mysql_query("select count(*) from candidati where id='$id'");
  309. $row=mysql_fetch_row($query);
  310. $nr=$row[0];
  311. if($nr==0)
  312. {
  313. $query1=mysql_query("insert into candidati values('$id','$nume','$prenume','$adresa','$media_bac','$media_multianuala_mate')");
  314. $query=mysql_query("select * from candidati where id='$id'");
  315. $nr_inreg=mysql_num_rows($query);
  316. if($nr_inreg>0)
  317. {
  318. echo "A fost adaugat";
  319. }
  320. else
  321. {
  322. echo "Nu a fost adaugat";
  323. }
  324. echo "<br> <a href='http://localhost/afisare.php'>Afisare</a>";
  325. }
  326. else
  327. {
  328. echo "Candidatul exista deja ";
  329. }
  330. ?>
  331.  
  332. //INSERARE HTML
  333.  
  334. <html>
  335. <body>
  336. <form action="http://localhost/inserare.php" method="POST">
  337. <table align="center" border="4" bgcolor="blue">
  338. <tr>
  339. <td>ID:</td>
  340. <td><input type="text" name="id_form"></td>
  341. </tr>
  342. <tr>
  343. <td>NUME:</td>
  344. <td><input type="text" name="nume_form"></td>
  345. </tr>
  346. <tr>
  347. <td>PRENUME:</td>
  348. <td><input type="text" name="prenume_form"></td>
  349. </tr>
  350. <tr>
  351. <td>ADRESA:</td>
  352. <td><input type="text" name="adresa_form"></td>
  353. </tr>
  354. <tr>
  355. <td>MEDIA BAC:</td>
  356. <td><input type="text" name="media_bac_form"></td>
  357. </tr>
  358. <tr>
  359. <td>MEDIA MULTIANUALA:</td>
  360. <td><input type="text" name="media_multianuala_mate_form"></td>
  361. </tr>
  362. <tr>
  363. <td><input type="submit" value ="adaugare"></td>
  364. </tr>
  365. </table>
  366. </form>
  367. </body>
  368. </html>
  369.  
  370.  
  371.  
  372. //AFISARE PHP
  373.  
  374. <?php
  375.  
  376. mysql_connect("localhost","root","") or die("Nu se poate conecta");
  377. mysql_select_db("admitere") or die("nu se gaseste bd");
  378. $query=mysql_query("select * from candidati");
  379. $nr_inreg=mysql_num_rows($query);
  380. if($nr_inreg>0)
  381. {
  382. echo"<table border='4' align='center'>";
  383. $coln=mysql_num_fields($query);
  384. echo"<tr bgcolor='red'>";
  385. for($i=0;$i<$coln;$i++)
  386. {
  387. $var=mysql_field_name($query,$i);
  388. echo "<td>$var</td>";
  389. }
  390. while($row=mysql_fetch_row($query))
  391. {
  392. echo"<tr>";
  393. foreach($row as $value)
  394. {
  395. echo "<th>$value</th>";
  396. }
  397. echo"</tr>";
  398. }
  399. echo "</tr>";
  400. echo "</table>";
  401. echo "La examenul de admitere s-au inscris : ".$nr_inreg." "."candidati";
  402. }
  403. else
  404. {
  405. echo "Nu s-a gasit nici o inregistare";
  406. }
  407. mysql_close();
  408.  
  409. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement