making an alert with php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shotokan99

    making an alert with php

    i have this code that when the user click it will delete the record:

    echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana"
    size="1">
    <a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'">de lete</a></
    font></td>';

    i wanted to do a little confirmation before commiting the action. how
    to do it?

    tnx

  • Erwin Moller

    #2
    Re: making an alert with php

    shotokan99 wrote:
    i have this code that when the user click it will delete the record:
    >
    echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana"
    size="1">
    <a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'">de lete</a></
    font></td>';
    >
    i wanted to do a little confirmation before commiting the action. how
    to do it?
    >
    tnx
    Wrong group again dude. ;-)

    Try comp.lang.javas cript.
    And it is easy.

    Regards,
    Erwin Moller

    Comment

    • Geoff Berrow

      #3
      Re: making an alert with php

      Message-ID: <4653f9c2$0$328 $e4fe514c@news. xs4all.nlfrom Erwin Moller
      contained the following:
      >i have this code that when the user click it will delete the record:
      >>
      >echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana"
      >size="1">
      > <a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'">de lete</a></
      >font></td>';
      >>
      >i wanted to do a little confirmation before commiting the action. how
      >to do it?
      >>
      >tnx
      >
      >Wrong group again dude. ;-)
      >
      >Try comp.lang.javas cript.
      EEEK! No! If that page ever accidentally got spidered, all the records
      would be deleted. Spiders don't run JavaScript, they just 'click'
      links.

      PHP would be better. I usually pass items to be deleted to an interim
      page (store them in a session or hidden field) and ask users to click a
      button to confirm the delete.



      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Joe Scylla

        #4
        Re: making an alert with php

        Geoff Berrow wrote:
        Message-ID: <4653f9c2$0$328 $e4fe514c@news. xs4all.nlfrom Erwin Moller
        contained the following:
        >
        >>i have this code that when the user click it will delete the record:
        >>>
        >>echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana"
        >>size="1">
        >> <a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'">de lete</a></
        >>font></td>';
        >>>
        >>i wanted to do a little confirmation before commiting the action. how
        >>to do it?
        >>>
        >>tnx
        >Wrong group again dude. ;-)
        >>
        >Try comp.lang.javas cript.
        >
        EEEK! No! If that page ever accidentally got spidered, all the records
        would be deleted. Spiders don't run JavaScript, they just 'click'
        links.
        >
        PHP would be better. I usually pass items to be deleted to an interim
        page (store them in a session or hidden field) and ask users to click a
        button to confirm the delete.
        well if a guest user (like a spider) is able to delete you've made
        something terrible wrong ;).

        Also afaik spider don't execute javascript code.

        I use a solution like this:

        <a href="#" onclick="gui_de lete('delete.ph p?id=123');">de lete</a>
        function gui_delete(url)
        {
        var r = confirm("Delete entry?");
        if (r)
        {
        document.locati on.href = url;
        }
        }

        Comment

        • Geoff Berrow

          #5
          Re: making an alert with php

          Message-ID: <f311au$11i$00$ 1@news.t-online.comfrom Joe Scylla
          contained the following:
          >well if a guest user (like a spider) is able to delete you've made
          >something terrible wrong ;).
          Agreed, but it happens. :-)
          >
          >Also afaik spider don't execute javascript code.
          >
          >I use a solution like this:
          >
          ><a href="#" onclick="gui_de lete('delete.ph p?id=123');">de lete</a>
          >function gui_delete(url)
          > {
          > var r = confirm("Delete entry?");
          > if (r)
          > {
          > document.locati on.href = url;
          > }
          > }

          Fair enough, but I don't like solutions that rely on JavaScript
          --
          Geoff Berrow (put thecat out to email)
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          • countach

            #6
            Re: making an alert with php

            En las nuevas, el shotokan99 escribió:
            i have this code that when the user click it will delete the record:
            >
            echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana"
            size="1">
            <a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'">de lete</a></
            font></td>';
            >
            i wanted to do a little confirmation before commiting the action. how
            to do it?
            >
            tnx

            A idea:


            $h='';
            switch ($_GET['delphase'])
            case 'conf':
            // Asking for delete
            $h.= 'Deleting file '.$id.'?<br>';
            $h.= '<a href="del.php?i d='.$id.'&dbf=' .$dbf_new.'&del phase=delok">OK !</a>
            ';
            $h.= '<a
            href="del.php?i d='.$id.'&dbf=' .$dbf_new.'&del phase=delcancel ">Cancel</a>';
            break;
            case 'delok':
            // Answer OK
            ulink ($id); // OR whatever you must do to delete the file
            $h.= 'File '.$id.' deleted!<br>';
            break;
            case 'delcancel':
            // Answer Cancel
            $h = 'Deleting file '.$id.' not done';
            // Not breaking to let normal text (default part) show
            default:
            // Normal behabiour, note the use of delphase parameter
            $h.= '<a
            href="del.php?i d='.$id.'&dbf=' .$dbf_new.'&del phase=conf">del ete</a>';
            break;
            }

            echo' <td bgcolor="'.$col or.'" width="40"><fon t face="Verdana" size="1">';
            echo $h;
            echo '</ font></td>';




            Hope it works for you.


            Comment

            • Toby A Inkster

              #7
              Re: making an alert with php

              How about...

              <a href="delete.ph p?id=123"
              onclick="return confirm_delete( this);">delete</a>

              function confirm_delete( link)
              {
              if (confirm("Delet e entry?"))
              {
              link.href += "&sure=1";
              return true;
              }
              else
              return false;
              }

              Where "delete.php " deletes the item instantly if $_GET['sure']==1 and asks
              for confirmation otherwise.

              --
              Toby A Inkster BSc (Hons) ARCS
              [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
              [OS: Linux 2.6.12-12mdksmp, up 88 days, 18:09.]

              The Great Wi-Fi Controversy

              Comment

              • Toby A Inkster

                #8
                Re: making an alert with php

                Joe Scylla wrote:
                well if a guest user (like a spider) is able to delete you've made
                something terrible wrong ;).
                Think about link prefetching plugins for browsers. Yes, these do exist.

                --
                Toby A Inkster BSc (Hons) ARCS
                [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                [OS: Linux 2.6.12-12mdksmp, up 88 days, 18:15.]

                The Great Wi-Fi Controversy

                Comment

                • Geoff Berrow

                  #9
                  Re: making an alert with php

                  Message-ID: <slhdi4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                  contained the following:
                  >Where "delete.php " deletes the item instantly if $_GET['sure']==1 and asks
                  >for confirmation otherwise.

                  Relies on JS being enabled.
                  --
                  Geoff Berrow (put thecat out to email)
                  It's only Usenet, no one dies.
                  My opinions, not the committee's, mine.
                  Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                  Comment

                  • Toby A Inkster

                    #10
                    Re: making an alert with php

                    Geoff Berrow wrote:
                    Message-ID: <slhdi4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                    contained the following:
                    >
                    >>Where "delete.php " deletes the item instantly if $_GET['sure']==1 and asks
                    >>for confirmation otherwise.
                    >
                    Relies on JS being enabled.
                    No it doesn't.

                    --
                    Toby A Inkster BSc (Hons) ARCS
                    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                    [OS: Linux 2.6.12-12mdksmp, up 88 days, 22:13.]

                    The Great Wi-Fi Controversy

                    Comment

                    • Geoff Berrow

                      #11
                      Re: making an alert with php

                      Message-ID: <9lvdi4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                      contained the following:
                      >Geoff Berrow wrote:
                      >
                      >Message-ID: <slhdi4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                      >contained the following:
                      >>
                      >>>Where "delete.php " deletes the item instantly if $_GET['sure']==1 and asks
                      >>>for confirmation otherwise.
                      >>
                      >Relies on JS being enabled.
                      >
                      >No it doesn't.
                      What am I missing? It's javascript that appends the 'sure' variable to
                      the URL and without that delete.php won't do anything.

                      --
                      Geoff Berrow (put thecat out to email)
                      It's only Usenet, no one dies.
                      My opinions, not the committee's, mine.
                      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                      Comment

                      • Toby A Inkster

                        #12
                        Re: making an alert with php

                        Geoff Berrow wrote:
                        What am I missing? It's javascript that appends the 'sure' variable to
                        the URL and without that delete.php won't do anything.
                        As I said, when ($_GET['sure']==1) is false, delete.php should display an
                        "are you sure?" form. (And although I didn't explicitly state it, I meant
                        that that form should not require Javascript.)

                        --
                        Toby A Inkster BSc (Hons) ARCS
                        [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                        [OS: Linux 2.6.12-12mdksmp, up 89 days, 2 min.]

                        The Great Wi-Fi Controversy

                        Comment

                        • Geoff Berrow

                          #13
                          Re: making an alert with php

                          Message-ID: <256ei4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                          contained the following:
                          >What am I missing? It's javascript that appends the 'sure' variable to
                          >the URL and without that delete.php won't do anything.
                          >
                          >As I said, when ($_GET['sure']==1) is false, delete.php should display an
                          >"are you sure?" form. (And although I didn't explicitly state it, I meant
                          >that that form should not require Javascript.)
                          But if delete.php is going to handle it like that (and indeed that's how
                          I'd do it) the Javascript is redundant. It just makes it a little
                          quicker for people with JS enabled, which is, I'll grant you good use of
                          JS, but hardly worth the effort in this case IMO.

                          --
                          Geoff Berrow (put thecat out to email)
                          It's only Usenet, no one dies.
                          My opinions, not the committee's, mine.
                          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                          Comment

                          • Jerry Stuckle

                            #14
                            Re: making an alert with php

                            Geoff Berrow wrote:
                            Message-ID: <256ei4-s96.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
                            contained the following:
                            >
                            >>What am I missing? It's javascript that appends the 'sure' variable to
                            >>the URL and without that delete.php won't do anything.
                            >As I said, when ($_GET['sure']==1) is false, delete.php should display an
                            >"are you sure?" form. (And although I didn't explicitly state it, I meant
                            >that that form should not require Javascript.)
                            >
                            But if delete.php is going to handle it like that (and indeed that's how
                            I'd do it) the Javascript is redundant. It just makes it a little
                            quicker for people with JS enabled, which is, I'll grant you good use of
                            JS, but hardly worth the effort in this case IMO.
                            >
                            Actually, I think Toby has the right idea. It is worth it to make it
                            easier for those who have javascript.

                            Javascript is a great tool - but all pages should degrade gracefully if
                            it is not enabled. And Toby's method does just that.

                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===

                            Comment

                            Working...