CODE
<?php
if ($submit == "click"){
$connection = mysql_connect (localhost, username, password);
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$result = mysql_db_query ("sadas_Testing", $query);
if ($result){
echo "Success!";
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}
mysql_close ();
}
else{
echo "
<html><body>
<form method=\"post\" action=\"testing.php\">
Enter your full name
<input type=\"text\" name=\"fullname\"></input><br>
Enter your email address
<input type=\"text\" name=\"email\"></input><br>
<input type=\"submit\" name=\"submit\" value=\"click\"></input>
</form>
</body></html>
";
}
?>
if ($submit == "click"){
$connection = mysql_connect (localhost, username, password);
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$result = mysql_db_query ("sadas_Testing", $query);
if ($result){
echo "Success!";
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}
mysql_close ();
}
else{
echo "
<html><body>
<form method=\"post\" action=\"testing.php\">
Enter your full name
<input type=\"text\" name=\"fullname\"></input><br>
Enter your email address
<input type=\"text\" name=\"email\"></input><br>
<input type=\"submit\" name=\"submit\" value=\"click\"></input>
</form>
</body></html>
";
}
?>
It writes people names and email adresses in MySQL database. My goals is to make the script:
1) refuse not valid email adresses;
2) refuse not full names (there should be at least two words in full name field, containing only letters).

