Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2011
    Messaggi
    22

    Evento con click su immagine

    Salve a tutti!

    Ho un piccolo problema...non macino bene per niente bene il php però fino ad ora me la ero "cavata" benino....

    Ho questo codice:


    Codice PHP:

    <html>
    <head>
    <title>Mofica - Reclutamento 3.0 By Caligola</title></head>
    <body>
    <form method='get' action="<?php echo $_SERVER['PHP_SELF']?>">
    <?php

    require("config.php");

    if (
    $_COOKIE["login"] == "OK")
    {
    ?>
    <h6>Torna alla [url="home.php"]Home Page[/url]</h6>
        


            I dati presenti nel database sono i seguenti:
        <table border=1>
        <tbody>
        
        <tr>
          <th>Reclutato:</th>
          <th>Reclutante:</th>
          <th>Data:</th>
          <th>Eventuale Risposta:</th>
          <th>M:</th>
          <th>C:</th>
        </tr>
        <?php
        $result 
    mysql_query("SELECT * FROM reclutamento") or die(mysql_error());

        while(
    $row mysql_fetch_array($result))
        {
        
    ?><tr>
        <th><?php echo "".$row['reclutato']."" ?></th>
        <th><?php echo "".$row['reclutante']."" ?></th>
        <th><?php echo "".$row['data']."" ?></th>
        <th><?php echo "".$row['risposta']."" ?></th>
        <th><input type="image" src="lap.png" name="modi" value="<?php echo "".$row['id']."" ?>"></th>
        <th><input type="image" src="can.png" name="canc" value="<?php echo "".$row['id']."" ?>" onclick='GET'></th>
        </tr>
        <?php
        
    }
        if(isset(
    $_GET['id']))
        {
        
    $id $_GET['canc'];
        echo 
    "$id";
        
    // Creo la query
        
    mysql_query("DELETE FROM reclutamento WHERE id = '$id';")
        or die(
    mysql_error());  
        echo 
    "Dati cancellati!
     Torna alla "
    ;?>[url="home.php"]Home Page[/url]<?php
        
    }
        
    ?>
        </tbody>
        </table>
    </body>
    </html>

    <?php
    }
    else
    {
    ?>
    <center>


    Accesso negato!</p>



    Effettua il[url="index.php"]Login[/url]</p>
    </center>
    <?php

    }
    ?>
    La stringa interessata è questa:
    Codice PHP:
    <input type="image" src="can.png" name="canc" value="<?php echo "".$row['id']."" ?>" onclick='GET'>
    Ne ho provate di tutte però con nessun risultato, praticamente quando permi sull'immagine canc.png mi dovrebbe eseguire la querry mysql_query("DELETE FROM reclutamento WHERE id = '$id';") il problema è uno...quando premo sull'immagine non succede un bel niente ho sbagliato sicuramente metodo di invio...perché non mi da nessun errore sql (ho provato ad eseguire la query in phpmyamdin e va bene) non mi scrive (usato per debug) l'id che va a cancellare "$_GET['canc']; echo "$id";" ...

    Mi date una mano??

  2. #2

    Re: Evento con click su immagine

    Codice PHP:

    <html>
    <head>
    <title>Mofica - Reclutamento 3.0 By Caligola</title></head>
    <body>
    <form method='get' action="<?php echo $_SERVER['PHP_SELF']?>">
    <?php

    require("config.php");

    if (
    $_COOKIE["login"] == "OK")
    {
    ?>
    <h6>Torna alla [url="home.php"]Home Page[/url]</h6>
        


            I dati presenti nel database sono i seguenti:
        <table border=1>
        <tbody>
        
        <tr>
          <th>Reclutato:</th>
          <th>Reclutante:</th>
          <th>Data:</th>
          <th>Eventuale Risposta:</th>
          <th>M:</th>
          <th>C:</th>
        </tr>
        <?php
        $result 
    mysql_query("SELECT * FROM reclutamento") or die(mysql_error());

        while(
    $row mysql_fetch_array($result))
        {
        
    ?><tr>
        <th><?php echo "".$row['reclutato']."" ?></th>
        <th><?php echo "".$row['reclutante']."" ?></th>
        <th><?php echo "".$row['data']."" ?></th>
        <th><?php echo "".$row['risposta']."" ?></th>
        <th><input type="image" src="lap.png" name="modi" value="<?php echo "".$row['id']."" ?>"></th>
        <th><input type="image" src="can.png" name="canc" value="<?php echo "".$row['id']."" ?>" onclick="javascript:location.href="<?php echo $_SERVER['PHP_SELF']?>?canc='+this.value+'"></th>
        </tr>
        <?php
        
    }
        if(isset(
    $_GET['canc']))
        {
        
    $id $_GET['canc'];
        echo 
    "$id";
        
    // Creo la query
        
    mysql_query("DELETE FROM reclutamento WHERE id = '$id';")
        or die(
    mysql_error());  
        echo 
    "Dati cancellati!
     Torna alla "
    ;?>[url="home.php"]Home Page[/url]<?php
        
    }
        
    ?>
        </tbody>
        </table>
    </body>
    </html>

    <?php
    }
    else
    {
    ?>
    <center>


    Accesso negato!</p>



    Effettua il[url="index.php"]Login[/url]</p>
    </center>
    <?php

    }
    ?>

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2011
    Messaggi
    22
    ??? non funziona....tra l'altro, ho usato momentaneamente il metodo get per vedere cosa diceva al server...e...heheheh gli da le coordinate dell'immagine in cui clicko :| e non l'id...è sbagliato forse quel echo rows id?

  4. #4
    Non funziona cosa significa? Che errore dà?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.