0

I have this weird thing going on with my button.This is my code for the button (book button in my website) which is not working in Firefox but works in google chrome and internet explorer. Is there anything that i can do to make it work in Firefox.

This is my code;

    $thisresult = mysqli_query($con,$sql);

    if($booking_info['check_out'] <= date('Y-m-d')){
        echo    "<button style=' ' type='submit'> <a href='booknow.php?id=".$id."'> Book now!</a></button>";
    } 
    else if(mysqli_num_rows($thisresult)>=1){
        echo "You have already booked this hotel!";
    } 
    else {
        echo "<button style=' ' type='submit'> <a href='booknow.php?id=".$id."'> Book now!</a></button>"; 
    }

}
E_p
  • 3,136
  • 16
  • 28
Amir HD
  • 21
  • 2
  • 1
    You can't put an anchor inside a button. – Barmar Apr 27 '17 at 22:56
  • well then chrome and internet explorer are wrong because this shouldn't work at all – developerwjk Apr 27 '17 at 22:57
  • @Barmar what do you mean by anchor? – Amir HD Apr 27 '17 at 22:59
  • @developerwjk why is that? – Amir HD Apr 27 '17 at 22:59
  • @developerwjk Since it's invalid HTML, browsers are allowed to interpret it however they want. Which includes making it work. – Barmar Apr 27 '17 at 23:00
  • Because of what Barmar said. – developerwjk Apr 27 '17 at 23:01
  • i have got rid of them and the button doesn't work now – Amir HD Apr 27 '17 at 23:02
  • As @Barmar says, the anchor inside the button is inappropriate. If you want to make the anchor _look_ like a button, you can style it in CSS. There is, however, another issue here. Without more information to go on, it looks like part of a booking form. In that case, the form should use the POST method, and you should use a proper submit button _without_ an anchor. The URL should be in the form’s `action` property, and the `id` should be in a hidden field. – Manngo Apr 27 '17 at 23:03
  • You can also use `formaction` in the submit button to set the URL that it submits to. – Barmar Apr 27 '17 at 23:04
  • Anyway, see the answers in the linked question for suggestions on how to do what you're trying to do. – Barmar Apr 27 '17 at 23:04
  • @Manngo i'm confused, is it possible if you can provide me with the code please? I'd appropriate a help, thanks! – Amir HD Apr 27 '17 at 23:13
  • @AmirHD With respect, I think you need to learn more about forms, submitting them, and how PHP process them. @Barmar’s suggestion to look at the duplicated question will answer your immediate question. – Manngo Apr 27 '17 at 23:22

0 Answers0