# PHP echo to display javascript alert

**URL:** <https://forum.kirupa.com/t/php-echo-to-display-javascript-alert/215174>\
**Category:** programming\
**Created:** [February 5, 2007, 5:51am UTC](https://forum.kirupa.com/t/php-echo-to-display-javascript-alert/215174 "2007-02-05T05:51:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leisuresuitlissy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/leisuresuitlissy/32/2109_2.png) [@leisuresuitlissy](https://forum.kirupa.com/u/leisuresuitlissy)\
**Post date:** [February 5, 2007, 5:51am UTC](https://forum.kirupa.com/t/php-echo-to-display-javascript-alert/215174/1 "2007-02-05T05:51:16Z")

</div>

Hi people, I’m very new to PHP and I want to put a javascript alert within a php thingo. The code I have looks like this:

```php
 
$the_email = false;    
if(eregi("^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", $_POST['email'])) {
 $the_email = true;
} else {
 
echo "<script language=javascript> alert('Please enter a valid email address, or I will kill you); </script>"; 
 
 $the_email = false;
}
if(!$the_email || !isset($_POST['name']) || !isset($_POST['message'])) {
 
echo "<script language=javascript> alert('Please enter your '+fName); </script>"; 
 
}

```

Can anyone see anything wrong with this? Any feedback would be appreciated.
