Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* funclib.php */
- <?php
- $i=1;
- $hostT;
- $userT;
- $passT;
- function recibir($host, $user, $pass) {
- $hostT=$host;
- $userT=$user;
- $passT=$pass;
- }
- function conectar($host, $user, $pass) {
- $conex = mysql_connect($host, $user, $pass);
- /*if (mysql_select_db($db, $conex)) {
- return $conex;
- } else {
- print (mysql_error());
- }*/
- return $conex;
- }
- function desconectar($conex) {
- mysql_close($conex);
- }
- function insertar() {
- if (!isset($accion)){
- echo"
- <h3>Guardar datos en la base</h3>
- <form name=\"form1\" method=\"post\" action=\"insertar.php?accion=insertar\">
- <table>
- <tr>
- <td>Juego</td><td>DVDs</td><td>Region</td><td>Wave</td><td>SSv</td><td>Stealth</td><td>Audio</td><td>Textos, Subs.</td>
- </tr>
- <tr>
- <td><input type=\"text\" name=\"nombre\"></td><td><input type=\"text\" name=\"discos\"></td><td><input type=\"text\" name=\"reg\"></td><td><input type=\"text\" name=\"w\"></td><td><input type=\"text\" name=\"ss\"></td><td><input type=\"text\" name=\"st\"></td><td><input type=\"text\" name=\"audio\"></td><td><input type=\"text\" name=\"text\"></td>
- </tr>
- <tr>
- <td><input type=\"submit\" name=\"Submit\" value=\"Insertar datos\"></td>
- </tr>
- </form>";
- } elseif(isset($accion)) {
- $nombre=$HTTP_POST_VARS["nombre"];
- echo $nombre;
- $discos=$HTTP_POST_VARS["discos"];
- $reg=$HTTP_POST_VARS["reg"];
- $w=$HTTP_POST_VARS["w"];
- $ss=$HTTP_POST_VARS["ss"];
- $st=$HTTP_POST_VARS["st"];
- $audio=$HTTP_POST_VARS["audio"];
- $text=$HTTP_POST_VARS["text"];
- $conex=conectar($hostT, $userT, $passT);
- if (mysql_select_db("zoby_5231271_lj", $conex)) {
- $result=mysql_query("INSERT INTO juegos (Juego,DVDs,Region,Wave,SSv,Stealth,Audio,Textos Subs)
- VALUES ('',$nombre,$discos,$reg,$w,$ss,$st,$audio,$text) ",$conex);
- echo"<h3>Los datos han sido guardados</h3>";
- } else {
- print (mysql_error());
- }
- desconectar($conex);
- }
- }
- function mostrar() {
- $conex=conectar("sql104.zobyhost.com", "zoby_5231271", "m4Sj0D10");
- mysql_select_db("zoby_5231271_lj", $conex);
- $result=mysql_query("SELECT * FROM juegos ORDER BY Juego",$conex);
- echo"<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\">
- <tr bgcolor=\"#FFFF66\">
- <td width=\"35%\"> <div align=\"left\"><font face=\"MS Serif\">Juego</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">DVDs</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">Region</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">Wave</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">SSv</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">Stealth</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">Audio</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">Textos, Subs.</font></div></td>
- </tr>
- ";
- while($row=mysql_fetch_row($result)){
- if (!is_odd($i)) {
- echo"<tr>
- <td width=\"35%\"><div align=\"left\"><font face=\"MS Serif\">$row[0]</font></div></td>
- <td width=\"5%\"><div align=\"center\"><font face=\"MS Serif\">$row[1]</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">$row[2]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[3]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[4]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[5]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[6]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[7]</font></div></td>
- </tr>";
- $i++;
- } else if (is_odd($i)) {
- echo"<tr bgcolor=\"#99CCCC\">
- <td width=\"35%\"><div align=\"left\"><font face=\"MS Serif\">$row[0]</font></div></td>
- <td width=\"5%\"><div align=\"center\"><font face=\"MS Serif\">$row[1]</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">$row[2]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[3]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[4]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[5]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[6]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[7]</font></div></td>
- </tr>";
- $i++;
- }
- } /* else {
- print (mysql_error());
- }*/
- echo"</table>";
- desconectar($conex);
- }
- function is_odd($number) {
- return $number & 1; // 0 = par, 1 = impar
- }
- ?>
- /* fin funcion insertar() de funclib */
- /* insertar.php */
- <?php
- include("funclib.php");
- ?>
- <html>
- <head>
- <title>insertar lineas en la base de datos</title>
- </head>
- <body>
- <?php
- $host=$_POST["host"];
- $user=$_POST["user"];
- $pass=$_POST["pass"];
- recibir($host, $user, $pass);
- insertar();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement