Jump to content

naverus

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by naverus

  1. Hello I hope that someone can help me i am trying to do the following: i am trying to do the following i have a login name and password and the redirects me depending on the level the works correctly.

     

     

     

    Table Users

     

    id_user

     

    user

     

    pass

     

    city

     

    Type

     

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

     

     

    Table City

     

    id_city

     

    id_student

     

    city

     

     

     

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

     

     

    Table Student

     

    id_student

     

    id_city

     

    name

     

    last name

     

    grade

     

    number card

     

    city

     

     

     

    -------------- login.php---------------------------------------------------------------------------------------------

     

     

     

    <form id="form1" name="form1" method="post" action="cargar_login.php">

     

    <table width="800" border="0" align="center" cellpadding="5" cellspacing="5">

    <tr>

    <td colspan="2">blablabla</td>

    </tr>

    <tr>

    <td width="370">User</td>

    <td width="389"><input type="text" name="user" id="user" /></td>

    </tr>

    <tr>

    <td>Password</td>

    <td><input type="text" name="pass" id="pass" /></td>

    </tr>

    <tr>

    <td><input type="submit" name="boton" id="boton" value="Send" /></td>

    </tr>

    </table>

    </form>

     

    --------------finish login.php (form)-------------------------------------------------------------------------------

     

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    example name of the teacher 

     

    name: Peter

     

    Pass .12345 or wteu12, wherever...

     

    City: Chicago

     

    Type :Teacher

     

     

     

     

     

    --------------Star cargar_login.php-------------------------------------------------------------------------------

     

    <?php 

    include"conexion/conexion.php";

    $consulta = "SELECT * FROM Users WHERE user = '{$_POST['user']}' AND pass = '{$_POST['pass']}'"; 

    $datos = mysql_query($consulta, $id); 

    $numDatos = @mysql_num_rows($datos); 

    if ($numDatos <= 0) {

     

    echo"</p>

    <p> </p>

    <p> </p>";

    echo"<link href='../stylesheets/tabla.css' rel='stylesheet' type='text/css' />";

    echo "<center><table width='800' border='0' cellpadding='5' cellspacing='5'>";

    echo"<tr>";

    echo"<td class='textoerror'>";

    echo "<img src='error.png' width='46' height='46'/>\n Error: User or Pass are Incorrect.\n<a href='login.php'>Tray Again</a>";

    echo""; 

    echo"</td>";

    echo"</tr>";

    echo"</table></center>";

    } if(isset($_POST["boton"]))

    {

    $user = $_POST['user'];

    $pass = $_POST['pass'];

    $user = stripslashes($user);

    $pass = stripslashes($pass);

    $user = mysql_real_escape_string($user);

    $pass = mysql_real_escape_string($pass);

    $sql = "SELECT * FROM Users WHERE (user= '$user') AND pass='$pass'";

    $resultados = mysql_query($sql);

    $count = mysql_num_rows($resultados);//counting table rows

    $derechos=mysql_fetch_array($resultados); //fetch contents from db

    @session_start();

    $_SESSION['usuario'] = $user;

     

    if($derechos['type'] == "Supadmin"){

    header("Location: supadmin/index.php"); // if userlevel admin

    }

    //if($derechos['type'] == "Admin"){

    //print "<meta http-equiv=Refresh content=\"2 ; url=admin/index.php\">";

    // if userlevel admin//}

    elseif($derechos['type'] == "Admin"){

    header("Location: admin/index.php"); // if userlevel admin

    }

    elseif($derechos['type'] == "Teacher"){

    header("Location: teacher/index.php"); // if userlevel teacher


     

    elseif($derechos['type'] == "Students"){

    header("Location: students/index.php"); // if userlevel students


    elseif($derechos['type'] == "Parents"){

     

    header("Location: parents/index.php"); // if userlevel parents


    }

    else

    { echo "The user or Password is not Correct!"; }

    ?>

     

    --------------finish cargar_login.php------------------------------------------------------------------------------------

     

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    Example he logs seccions teacher : Peter and called a teacher/index.php and already registered to be able to see all the students of teacher Peter, who lives in Chicago and he want to see all the students of Chicago in the main section of teacher (teacher/index.php).

     

    I think that to bring the data of teacher Peter what i have to do with the union of two tables i suppose that this is the Users and City and the union is for :id_city

     

    --------------this are secciob of teacher/index.php------------------------------------------------------------------------------------

     

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    <?php session_start();

    if(!isset($_SESSION['user'])) 

    {

    header('Location: ../login.php'); 

    exit();


    $usuario = $_POST['user'];

    $clave = $_POST['pass'];

     

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    And here is where you should get a list of all the students of the teacher Peter who is from Chicago

     

    In the code sample below(teacher/index.php) already concerned in many ways but i can't ... Help as i do so is what I do not understand please help 

     

    I know that the code is bad, but this is my idea try to do this code...or call

     

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    --------------Satr teacher/index.php------------------------------------------------------------------------------------

     

    $id = mysql_connect("localhost", "root", "");

    mysql_select_db("nueva", $id); 

    $consulta_mysql="select User.*, city.* FROM user, city WHERE (user= '$user') AND pass='$pass";

    $res=mysql_query($consulta_mysql,$id); 

     

    if (!$res) { 

    die('Error in the table: ' . mysql_error()); 


     

     

    while($registro=mysql_fetch_array($res)) 


    echo"<td>";

    echo $registro["user"] ; 

    echo"</td>";

    echo"<td>";

    echo $registro["city"] ; 

    echo"</td>";

     


     

    ?>

     

     

     

  2. Hello I hope someone can help me
     
    I'm doing an example with a web cam in php and sql and order form and send it to a pdf to print, my problem is I can not get the picture, and only passes the address of the image and repeated twice the extension ". jpg "and make as a link in the pdf.
    i dont now what is my problem.
     

     
     
     
     
    this  are  my database sql
     
    /////////////////////////////////////// database sql /////////////////////////////////////////////////
     
     
    --
    -- Estructura de tabla para la tabla `fotos`
    --
     
    CREATE TABLE IF NOT EXISTS `fotos` (
      `id_foto` varchar(20) NOT NULL,
      `nombre` varchar(255) NOT NULL,
      `des` text NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     
     
    ////////////////////////  FIN DE BASE DE DATOS /////////////////////////////////////////////////
     
     
     
    this are my  code of: clase_conexion.php.php
     
    /////////////////////////////////////// CONEXION /////////////////////////////////////////////////
     
    <?php
    class conexion{
    var $serv="localhost";
    var $usuario="*******";
    var $contra="******";
    var $conexi;
    function conecta()
    {
    $s=$this->serv;
    $u=$this->usuario;
    $c=$this->contra;
    $conex=mysql_connect($s,$u,$c);
    $this->conexi=$conex;
    }
     
    }
    $cono= new conexion();
    $cono->conecta();
    $c=$cono->conexi;
    $select=mysql_select_db("progresa_webcam",$c);
    ?>
     
     
     
     
     
    ///////////////////////////////////End of conexion/////////////////////////////////////////////
     
     
     
    this are my  code of:: index.php
     
    /////////////////////////////////////// INDEX /////////////////////////////////////////////////
     
     
    <style type="text/css">
     
    /* jQuery lightBox plugin - Gallery style */
     
    #cuadro_camara {
     
    background-color: #444;
     
    padding-left: 30px;
     
    padding-top:20px;
     
    }
     
    #titulo_camara {
     
    background-color: #666;
     
    color:#FFF;
     
    padding-left: 30px;
     
    font-size: 14px;
     
    text-align:center;
     
    }
     
    .botones_cam {
     
    background-color:#FFF;
     
    color:#333;
     
    font-family: "Comic Sans MS", cursive;
     
    font-size:14px;
     
    margin-top:10px;
     
    width:120px;
     
    height:40px;
     
    }
     
    .formulario {
     
    color: #FFF;
     
    }
     
     
     
    </style>
     
    <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
     
    <script type="text/javascript" src="jquery.lightbox-0.5.js"></script>
     
    <link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />
     
    <script type="text/javascript" src="webcam.js"></script>
     
        <script language="JavaScript">
     
    webcam.set_api_url( 'test.php' );//PHP adonde va a recibir la imagen y la va a guardar en el servidor
     
    webcam.set_quality( 90 ); // calidad de la imagen
     
    webcam.set_shutter_sound( true ); // Sonido de flash
     
    </script>
     
    <script language="JavaScript">
     
    webcam.set_hook( 'onComplete', 'my_completion_handler' );
     
     
     
    function do_upload() {
     
    // subir al servidor
     
    document.getElementById('upload_results').innerHTML = '<h1>Cargando al servidor...</h1>';
     
    webcam.upload();
     
    }
     
     
     
    function my_completion_handler(msg) {
     
     
     
    if (msg.match(/(http\:\/\/\S+)/)) {
     
    var image_url = RegExp.$1;//respuesta de text.php que contiene la direccion url de la imagen
     
     
     
    // Muestra la imagen en la pantalla
     
    document.getElementById('upload_results').innerHTML = 
     
    '<img src="' + image_url + '">'+
     
    '<form action="gen.php" method="post">'+
                        
     
    '<input type="hidden" name="id_foto" id="id_foto" value="'+ image_url + '"  /><br>'+
     
    '<tr><td><label>Nombre</td><td></label><input type="text" name="nombre" id="nombre"/></td></tr><br />'+
     
    '<tr><td><label>Descripcion</label></td><td><input type="text" name="des" id="des"/></td></tr>'+
     
    //'<label>Escuelas</label><select name="select" id="select"><option value="casa">casa</option><option value="casa2">casa2</option><option value="casa3">casa3</option></select>'+
     
       '<input type="submit" name="button" id="button" value="Enviar" /></form>';
     
    // reset camera for another shot
     
    webcam.reset();
     
    }
     
    else alert("PHP Error: " + msg);
     
    }
     
    </script>
     
    <div align="left" id="cuadro_camara">    
     
     
     
    <table width="100%" height="144"><tr><td width="124" valign=top>
     
    <form>
     
    <input type=button value="Configurar Camara" onClick="webcam.configure()" class="botones_cam">
     
      
     
    <input type=button value="Tomar foto" onClick="webcam.freeze()" class="botones_cam">
     
      
     
    <input type=button value="Subir" onClick="do_upload()" class="botones_cam">
     
      
     
    <input type=button value="Borrar" onClick="webcam.reset()" class="botones_cam">
     
    </form>
     
     
     
    </td>
     
        <td width="212" valign=top>
     
    <script language="JavaScript">
     
    document.write( webcam.get_html(320, 240) );//dimensiones de la camara
     
    </script>
     
        </td>
     
        <td width=370>
     
       <div id="upload_results" class="formulario" > </div>
     
      </td></tr></table><br /><br />
     
    </div>
     
     
     
     
     
     
     
    <br />
     
    <br />
     
    <script type="text/javascript">
     
        $(function() {
     
            $('#gallery a').lightBox();//Galeria jquery
     
        });
     
        </script>
     
        <style type="text/css">
     
    /* jQuery lightBox plugin - Gallery style */
     
    #gallery {
     
    background-color: #444;
     
    width: 100%;
     
    }
     
    #gallery ul { list-style: none; }
     
    #gallery ul li { display: inline; }
     
    #gallery ul img {
     
    border: 5px solid #3e3e3e;
     
    border-width: 5px 5px 5px;
     
    }
     
    #gallery ul a:hover img {
     
    border: 5px solid #fff;
     
    border-width: 5px 5px 5px;
     
    color: #fff;
     
    }
     
    #gallery ul a:hover { color: #fff; }
     
    </style>
     
        
     
        <div id="gallery">
     
        <ul>
     
      <?php  
     
      
     
      include("clase_conexion.php");
     
      $consulta="select * from fotos order by id_foto desc";
     
      $busca_fotos=mysql_query($consulta,$c);
     
      while($row=mysql_fetch_array($busca_fotos)){
     
     
       $url=$row['id_foto'];  
     
       $nombre=$row['nombre']; 
     
         $des=$row['des'];
     
         echo "<li>
     
                <a href=\"fotos/".$url.".jpg\" title=\"<a href=ver.php?nombre=".$nombre." ['id'] target='_blank'>Informacion del Alumno\">
     
                <img src=\"fotos/".$url.".jpg\" width=\"150\" height=\"120\" alt=\"\" /></a>
     
            </li>";
     
      }
     
    ?>    
     
        </ul>
     
    </div>
     
    ///////////////////////////////////END  INDEX/////////////////////////////////////////////
     
     
    this are my  code of: ver.php
     
     
    /////////////////////////////////////// SEE/////////////////////////////////////////////////
     
     
    <?php 
     // Connects to your Database 
     include("clase_conexion.php");
     $consulta = mysql_query("SELECT id_foto, nombre, des FROM fotos WHERE nombre like'%".$_GET["nombre"]."%'
    or id_foto like'%".$_GET["nombre"]."%'") 
     or die(mysql_error()); 
      $info = mysql_fetch_array( $consulta );
      
      $url=$info['id_foto'];  
       $nombre=$info['nombre']; 
         $des=$info['des'];
      
         
     echo "<b>Nombre</b> ".$info['nombre'] . " <br>"; 
     echo "<b>Descripcion</b> ".$info['des'] . " <br>";
     echo"<img src = \"fotos/".$info['id_foto'].'.jpg  "height=100 width=100"'."\" />";
     //echo "<a href=gen.php?id_foto=.$url ['id_foto ']target='_blank'>Imprimir Credencial del Alumno\>";
     echo"<a href='#'>hola</a>";
     
     ?> 
     
    ///////////////////////////////////END OF SEE/////////////////////////////////////////////
     
     
    this are my  code of:  gen.php
     
     
    /////////////////////////////////////// GEN /////////////////////////////////////////////////
     
    <?php
    /* incluimos primeramente el archivo que contiene la clase fpdf */
    include ('pdf/fpdf.php');
       /* tenemos que generar una instancia de la clase */
            $pdf = new FPDF();
            $pdf->AddPage();
     
    /* seleccionamos el tipo, estilo y tamaño de la letra a utilizar */
            $pdf->SetFont('Helvetica', 'B', 14);
    $pdf->Write (7,"...");
    $pdf->Ln();
    $pdf->Write(7,$_POST['id_foto'].'.jpg' );
    $pdf->Ln(); //salto de linea
    $pdf->Cell(60,7,$_POST['nombre'],1,0,'C');
    $pdf->Ln(15);//ahora salta 15 lineas 
    $pdf->SetTextColor('255','0','0');//para imprimir en rojo 
    $pdf->Multicell(190,7,$_POST['des']."...",1,'R');
    $pdf->Line(0,160,300,160);//impresión de linea
            $pdf->Output("prueba.pdf",'F');
    echo "<script language='javascript'>window.open('prueba.pdf','_self','');</script>";//para ver el archivo pdf generado
    exit;
    ?>
     
     
    ///////////////////////////////////END OF GEN/////////////////////////////////////////////
     
     
    i dont now  where is  the  problem i understand what happend pls  help me 

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.