0
if(isset($_POST['check'])){
    $email =  $_POST['email'];
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) { 
       echo '<script language="javascript">'; 
       echo 'alert(Valid email)';   
       echo '</script>';
    } else { 
       echo '<script language="javascript">'; 
       echo 'alert(Not valid email)';   
       echo '</script>';     
    }
}

i'm trying to show an alert with the result but it's not working. however echo a text working but not JS alert.

why is that? is there another way to do that?

4
  • language="javascript" is dead and gone Commented Nov 13, 2021 at 12:25
  • 3
    Missing quotes for the strings you want to alert? Wouldn't your browser console give a hint on that? Commented Nov 13, 2021 at 12:26
  • 3
    i.e. echo 'alert("Valid email")'; Commented Nov 13, 2021 at 12:26
  • yes missing quotes, it's working. thank you Commented Nov 13, 2021 at 12:30

1 Answer 1

1

put '<script type="application/javascript">' instead of '<script language="javascript">'

yout script tag attribute is wrong and also you use alert function wrong. change alert(Valid email) to alert("Valid email") and change alert(Not valid email) to alert("Not valid email").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.