Jump to content

Suggestions on shortening


Praetorian
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...