input type="image" $_POST queries

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

    input type="image" $_POST queries

    Hi all,

    I'm trying to set up a 'control panel' consisting of a table of icons.

    The early stages: http://www.deepinit.com/controlcentre.php

    Each of these is set up like:

    <td>
    <input type="image" id="addnews" src="/Image/add24.png"
    name="addnews" value="addnews" width="24" height="24"><br />
    <label for="addnews">A dd News Item</label><br />
    </td>

    This is all taking place in a html form and I'm using input
    type="image"... like 'submit' buttons.

    Is this a 'good' approach?

    I'm trying to handle the $_POST variable after a user clicks on one of
    these but there are differences between firefox and ie6.

    Using:
    foreach ($_POST as $key=>$val) {
    echo $key ."|". $val . "<br />";
    }

    ie6 is only listing
    addnews_x|8
    addnews_y|17


    Firefox:
    addnews_x|10
    addnews_y|13
    addnews|addnews

    Why am I getting x and y co-ordinates?

    Why in firefox do I get $val ('addnews|addne ws') but not in ie6?

    What I'm trying to do is redirect to other pages based on $_POST:

    foreach ($_POST as $key=>$val) {
    switch (strtolower($ke y)) {
    case 'addnews_x':
    PostHandler('ad dnews', 'news', '/posteditor.php' );
    break;
    case 'editnews_x':
    PostHandler('ed itnews', 'news', '/postsearch.php' );
    break;
    case 'deletenews_x':
    PostHandler('de letenews', 'news', '/postsearch.php' );
    break;
    ...

    function PostHandler($co mmand, $post_type, $redir_page) {
    $_SESSION['ctlcentcmd'] = $command;
    $_SESSION['posttype'] = $post_type;

    ob_end_clean();
    header('Locatio n: http://' . $_SERVER['HTTP_HOST']
    . $redir_page);
    }


    This is working but I'm not happy basing this on the x co-ordinate
    (eg addnews_x). Surely there must be a better way?

    If you wanted to implement a similar icon based 'Control Centre' what
    approach would you take? The intent is to have a single page where the
    site admin can add/edit/delete news, articles, bios, user data, etc


    thanks for your help,

    --
    Mark



  • flamer die.spam@hotmail.com

    #2
    Re: input type=&quot;imag e&quot; $_POST queries

    Since your using an image in an input field then that information is
    being submitted by post to (the image is). Thats fine, just access each
    post variable indivually (yes it takes a bit longer but as you have
    seen IE and FF differ)

    so just get your vars as so: $submitedname = $_POST['name'];

    Flamer.

    Mark Woodward wrote:
    Hi all,
    >
    I'm trying to set up a 'control panel' consisting of a table of icons.
    >
    The early stages: http://www.deepinit.com/controlcentre.php
    >
    Each of these is set up like:
    >
    <td>
    <input type="image" id="addnews" src="/Image/add24.png"
    name="addnews" value="addnews" width="24" height="24"><br />
    <label for="addnews">A dd News Item</label><br />
    </td>
    >
    This is all taking place in a html form and I'm using input
    type="image"... like 'submit' buttons.
    >
    Is this a 'good' approach?
    >
    I'm trying to handle the $_POST variable after a user clicks on one of
    these but there are differences between firefox and ie6.
    >
    Using:
    foreach ($_POST as $key=>$val) {
    echo $key ."|". $val . "<br />";
    }
    >
    ie6 is only listing
    addnews_x|8
    addnews_y|17
    >
    >
    Firefox:
    addnews_x|10
    addnews_y|13
    addnews|addnews
    >
    Why am I getting x and y co-ordinates?
    >
    Why in firefox do I get $val ('addnews|addne ws') but not in ie6?
    >
    What I'm trying to do is redirect to other pages based on $_POST:
    >
    foreach ($_POST as $key=>$val) {
    switch (strtolower($ke y)) {
    case 'addnews_x':
    PostHandler('ad dnews', 'news', '/posteditor.php' );
    break;
    case 'editnews_x':
    PostHandler('ed itnews', 'news', '/postsearch.php' );
    break;
    case 'deletenews_x':
    PostHandler('de letenews', 'news', '/postsearch.php' );
    break;
    ...
    >
    function PostHandler($co mmand, $post_type, $redir_page) {
    $_SESSION['ctlcentcmd'] = $command;
    $_SESSION['posttype'] = $post_type;
    >
    ob_end_clean();
    header('Locatio n: http://' . $_SERVER['HTTP_HOST']
    . $redir_page);
    }
    >
    >
    This is working but I'm not happy basing this on the x co-ordinate
    (eg addnews_x). Surely there must be a better way?
    >
    If you wanted to implement a similar icon based 'Control Centre' what
    approach would you take? The intent is to have a single page where the
    site admin can add/edit/delete news, articles, bios, user data, etc
    >
    >
    thanks for your help,
    >
    --
    Mark

    Comment

    • Kimmo Laine

      #3
      Re: input type=&quot;imag e&quot; $_POST queries

      "Mark Woodward" <markonlinux@in ternode.on.netw rote in message
      news:pan.2006.0 7.10.11.12.12.7 10395@internode .on.net...
      Hi all,
      >
      I'm trying to set up a 'control panel' consisting of a table of icons.
      >
      The early stages: http://www.deepinit.com/controlcentre.php
      >
      Each of these is set up like:
      >
      <td>
      <input type="image" id="addnews" src="/Image/add24.png"
      name="addnews" value="addnews" width="24" height="24"><br />
      <label for="addnews">A dd News Item</label><br />
      </td>
      >
      This is all taking place in a html form and I'm using input
      type="image"... like 'submit' buttons.
      >
      Is this a 'good' approach?
      >
      I'm trying to handle the $_POST variable after a user clicks on one of
      these but there are differences between firefox and ie6.
      >
      Using:
      foreach ($_POST as $key=>$val) {
      echo $key ."|". $val . "<br />";
      }
      >
      ie6 is only listing
      addnews_x|8
      addnews_y|17
      >
      >
      Firefox:
      addnews_x|10
      addnews_y|13
      addnews|addnews
      >
      Why am I getting x and y co-ordinates?
      >
      Why in firefox do I get $val ('addnews|addne ws') but not in ie6?
      "Creates a graphical submit button. The value of the src attribute specifies
      the URI of the image that will decorate the button. For accessibility
      reasons, authors should provide alternate text for the image via the alt
      attribute.

      When a pointing device is used to click on the image, the form is submitted
      and the click coordinates passed to the server. The x value is measured in
      pixels from the left of the image, and the y value in pixels from the top of
      the image. The submitted data includes name.x=x-value and name.y=y-value
      where "name" is the value of the name attribute, and x-value and y-value are
      the x and y coordinate values, respectively." From:


      Note that php will convert name.x to name_x and name_y since period is
      invalid in variable name.

      What I'd like to know is what happens in IE if images are disabled or
      non-existing image uri is given, and form is submitted by clicking the image
      input which is converted to normal submit button, is the actual name then
      provided? Are the coordinates (0,0) provided?

      --
      "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
      spam@outolempi. net | Gedoon-S @ IRCnet | rot13(xvzzb@bhg byrzcv.arg)


      Comment

      • Mark Woodward

        #4
        Re: input type=&quot;imag e&quot; $_POST queries

        Thanks guys,

        On Tue, 11 Jul 2006 12:59:10 +0300, Kimmo Laine wrote:
        "Creates a graphical submit button. The value of the src attribute specifies
        the URI of the image that will decorate the button. For accessibility
        reasons, authors should provide alternate text for the image via the alt
        attribute.
        >
        When a pointing device is used to click on the image, the form is submitted
        and the click coordinates passed to the server. The x value is measured in
        pixels from the left of the image, and the y value in pixels from the top of
        the image. The submitted data includes name.x=x-value and name.y=y-value
        where "name" is the value of the name attribute, and x-value and y-value are
        the x and y coordinate values, respectively." From:

        >
        Note that php will convert name.x to name_x and name_y since period is
        invalid in variable name.
        >
        What I'd like to know is what happens in IE if images are disabled or
        non-existing image uri is given, and form is submitted by clicking the image
        input which is converted to normal submit button, is the actual name then
        provided? Are the coordinates (0,0) provided?
        Kimmo, I just disabled images in ie6 so I'm only see the placeholders. It
        still works as though the image was there (ie getting the x and y coords).


        --
        Mark

        Comment

        • Mel

          #5
          Re: input type=&quot;imag e&quot; $_POST queries

          On 2006-07-10 21:12:13 +1000, Mark Woodward
          <markonlinux@in ternode.on.nets aid:
          Hi all,
          >
          I'm trying to set up a 'control panel' consisting of a table of icons.
          >
          The early stages: http://www.deepinit.com/controlcentre.php
          >
          Each of these is set up like:
          >
          <td>
          <input type="image" id="addnews" src="/Image/add24.png"
          name="addnews" value="addnews" width="24" height="24"><br />
          <label for="addnews">A dd News Item</label><br />
          </td>
          >
          This is all taking place in a html form and I'm using input
          type="image"... like 'submit' buttons.
          Is this a 'good' approach?
          >
          I'm trying to handle the $_POST variable after a user clicks on one of
          these but there are differences between firefox and ie6.
          Using:
          foreach ($_POST as $key=>$val) {
          echo $key ."|". $val . "<br />";
          }
          >
          ie6 is only listing
          addnews_x|8
          addnews_y|17
          >
          >
          Firefox:
          addnews_x|10
          addnews_y|13
          addnews|addnews
          Why am I getting x and y co-ordinates?
          Why in firefox do I get $val ('addnews|addne ws') but not in ie6?
          >
          What I'm trying to do is redirect to other pages based on $_POST:
          >
          foreach ($_POST as $key=>$val) {
          switch (strtolower($ke y)) {
          case 'addnews_x':
          PostHandler('ad dnews', 'news', '/posteditor.php' );
          break;
          case 'editnews_x':
          PostHandler('ed itnews', 'news', '/postsearch.php' );
          break;
          case 'deletenews_x':
          PostHandler('de letenews', 'news', '/postsearch.php' );
          break;
          ...
          >
          function PostHandler($co mmand, $post_type, $redir_page) {
          $_SESSION['ctlcentcmd'] = $command;
          $_SESSION['posttype'] = $post_type;
          >
          ob_end_clean();
          header('Locatio n: http://' . $_SERVER['HTTP_HOST']
          . $redir_page);
          }
          >
          >
          This is working but I'm not happy basing this on the x co-ordinate
          (eg addnews_x). Surely there must be a better way?
          >
          If you wanted to implement a similar icon based 'Control Centre' what
          approach would you take? The intent is to have a single page where the
          site admin can add/edit/delete news, articles, bios, user data, etc
          >
          >
          thanks for your help,
          I'd be inclined to make them buttons and use CSS to style them out to
          be images (turn off the borders, specify a width and height, set a
          background-image). From there you can either use them to sumit to a
          page using AJAX, JavaScript, or a plain old form.

          Comment

          • Mark Woodward

            #6
            Re: input type=&quot;imag e&quot; $_POST queries

            Hi Mel,

            On Wed, 12 Jul 2006 00:05:19 +1000, Mel wrote:
            I'd be inclined to make them buttons and use CSS to style them out to
            be images (turn off the borders, specify a width and height, set a
            background-image). From there you can either use them to sumit to a
            page using AJAX, JavaScript, or a plain old form.
            I'd be inclined to agree with you ;-)
            Just tried this and it seems much cleaner!!

            thanks,

            --
            Mark

            Comment

            Working...