Help: Simple html/php button....

Discussion in 'PHP' started by Skillman13, Jan 21, 2010.

  1. #1
    I have a button, I want it to echo something after it is clicked...

    I have this (example echo/code)...

    <form method="post" action="">
    <input src="delete.png" name="delete" type="image" value="delete" >
    </form>
    <?

    if(!empty($_POST['delete'])) {

    echo "Hi";

    }

    ?>



    I run this on firefox and it works, -Echos 'Hi'...

    I run this on IE and it doesnt work, -it refreshes the page, but no 'Hi' is loaded, how come?

    Please can anyone fix this?

    Thanks...

    James
     
    Skillman13, Jan 21, 2010 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When you click an image button in IE you get $_POST['delete_x'] and $_POST['delete_y'] reflecting the exact coordinates of where the user clicked.

    So you need to check whether either $_POST['delete'] or $_POST['delete_x'] is set, not just the first.
     
    SmallPotatoes, Jan 21, 2010 IP
  3. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ahhh ok thanks, so how can i do that? /assign values? or do i just do it as u said?
     
    Skillman13, Jan 21, 2010 IP
  4. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok great thanks :) Working...
     
    Skillman13, Jan 21, 2010 IP
  5. TimothyJohn

    TimothyJohn Member

    Messages:
    786
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    35
    #5
    Sucks that people still even use IE, life would be so much easier if the whole world just used Firefox haha
     
    TimothyJohn, Jan 21, 2010 IP
  6. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah... :p
     
    Skillman13, Jan 22, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    You could do:

    <form method="post" action="#">
    <input src="delete.png" name="delete" type="image" value="delete" >
    </form>
    <?php
    
    if(isset($_POST['delete'])) {
    
    echo "Hi";
    
    }
    
    ?>
    Code (markup):
     
    danx10, Jan 23, 2010 IP
  8. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    pfft firefox is for squares =) ie works just fine. but opera, now that a browser
     
    dmanto2two, Jan 23, 2010 IP
  9. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #9
    Use Google Chrome! I only started using it the other day but I'm already liking it alot. It even has a built in spell check and is very fast!
     
    Silver89, Jan 23, 2010 IP
  10. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #10
    That won't work in IE; that was his original problem.
     
    SmallPotatoes, Jan 24, 2010 IP