Hello I am trying to write a form that checks user mail address by existence of "@" character. I wrote these codes below but when I enter information at the html file I get this warning:

Notice: Use of undefined constant mail - assumed 'mail' in C:\xampp\test\send_simpleform.php on line 2

Can you please tell me why am I getting this notice? Thanks a lot. Here is the html file

<title>A simple HTML form</title>
<form action="send_simpleform.php" method="POST">
<input type="text" name="user"></p>
<input type="text" name="mail"></p>
<p><input type="submit" value="send"></p>

and this is the send_simpleform.php file's code:

echo "<p>Welcome <b>$_POST[user]</b>!</p>";
//echo "<p>Your message is:<br><b>$_POST[message]</b></p>";
echo"<p>Your e-mail address seems invalid. Please go back and enter a valid address.</p>"

Thank you very much


should be


the single quotes. Your form though is not effective. Here is a simple function that checks if the entire email has been formatted correctly.

function ValidEmail($email) {//checks if the email is in a valid foramat
	return preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i",trim($email));

basically put the function in a separate file called functions.inc.php and call it from your contact page by putting the following on the first line of the php code at top of send_simpleform.php page

require_once 'functions.inc.php';

that way you can easily call the function with:

if(ValidEmail($email)) {

wow, that really helped, thank you very much!