Jump to content

Suggestions on shortening


Praetorian

Recommended Posts

Simple request. I coded this script for a simple email form. Everything works fine. I'm just wondering if anyone can suggest any ways to make this more efficient/shorter.Thanks in advance.

<?php                    $Name = $_REQUEST["Name"];                    $Email = $_REQUEST["Email"];                    $Message = $_REQUEST["Message"];                    if ($Email != "" and $Name != "" and $Message !="")                    {                        if (!eregi("[a-z]", $Name) and !eregi("^[a-z0-9]+([!#$%*/?|^{}`~&'+-=_][a-z0-9])*@[a-z0-9]+([!#$%*/?|^{}`~&'+-=_][a-z0-9])*.[a-z]{2,3}$", $Email))                        	{								echo "<h3>Please enter a valid name.</h3>";								echo "<h3>Please Enter a Valid Email Address.</h3>";								include 'mailform.txt';							}                        elseif (!eregi("[a-z]", $Name))                        	{								echo "<h3>Please enter a valid name.</h3>";								include 'mailform.txt';							}                        elseif (!eregi("^[a-z0-9]+([!#$%*/?|^{}`~&'+-=_][a-z0-9])*@[a-z0-9]+([!#$%*/?|^{}`~&'+-=_][a-z0-9])*.[a-z]{2,3}$", $Email))                        	{                                echo "<h3>Please Enter a Valid Email Address.</h3>";                                include 'mailform.txt';                            }                        else                            {                                mail( "author@tsrealms.com",$Name,$Message,"From: $Email" );                                echo "<h1>Thank you for your message! One of the admins should be getting back to you via email within 24 hours.</h1>";                            }                    }                                        else                                        {						echo "<h3>One or more fields are not filled out. Please try again.</h3>";						include 'mailform.txt';					}                ?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...