use alert box in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tiwi
    New Member
    • Feb 2007
    • 1

    use alert box in php

    i want to use alert box in php but i'm confuse because alert box usually used in javascript. i want to use the alert box to control the condition if the user doesn't habe account to enter my website. can anybody help me? thanks
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    PHP does not have an alert box identical to JS, but you can construct a box just like that (using CSS) in PHP and display that on the screen.

    Ronald :cool:

    Comment

    • xwero
      New Member
      • Feb 2007
      • 99

      #3
      You could go another way. Output the alert text to an html element with a certain class or id and then check with javascript if the element has content and if it has display an alert.

      For the example i will use jquery to code the javascript side.

      [PHP]
      if($var == 'bad'){
      echo '<p id="error">You made a bad move</p>';
      }
      [/PHP]

      Code:
      $(function(){
          var error =  $('#error').text();
          if(error.length > 0){ alert(error); }
      });
      IMHO on the javascript side there are nicer solutions then an alert box.

      Comment

      Working...