<?php

// Change these two variables to meet your needs.

$myemail = 'ema@cervion.com';
$subject = 'Email List Signup: Customer Portal';

$op = $_POST[op];

if($op == 'contact')
{
    $name = stripslashes($_POST[name]);
	$email = stripslashes($_POST[email]);
    $referer = $_POST[referer];
    $remote_host = $_SERVER[REMOTE_ADDR];
    $server = $_SERVER[SERVER_NAME];
    $browser = $_SERVER[HTTP_USER_AGENT];
	$ip = $_SERVER[REMOTE_ADDR];
	$datestamp = date("m-d-Y H:i:s"); 

    if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",$email)) 
    { 
        $status = "<b><font color=red>Email not valid.</font></b><br>";
    }
    if(!$name)
    {
        $status .= "<b><font color=red>Enter your name.</font></b>";
    }

    if(!$status)
    {
        $header = "From: $email";

        $message = "
Cervion Systems, Inc.
Email Signup - Form Message
-----
Submission Date/Time: $datestamp
-----
Customer IP Address: $ip
-----
Name: $name
eMail: $email
			
        "; 

        if(mail($myemail, $subject, $message, $header))
        {
            $status = "<b><font color=red>Thank You!</font></b>";
        }
        else
        {
            $status = "<b><font color=red>Please try again.</font></b>";
        }

    }
}    

// Now check the referer page and ensure it's a proper URL

$referer = $_SERVER[HTTP_REFERER];

if(!preg_match('#^http\:\/\/[a-z0-9-]+.([a-z0-9-]+.)?[a-z]+#i', $referer))
{
    unset($referer);
}

?>
<form method="post" action="<?php print $_SELF; ?>">
                    <input type="hidden" name="op" value="contact" />
                    <input type="hidden" name="referer" value="<?php print $referer; ?>" />
                    <table width="257" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="45" align="right" class="form-title">NAME</td>
                        <td width="10">&nbsp;</td>
                        <td width="202" height="40"><input name="name" type="text" class="textfield" id="textfield" size="30" /></td>
                      </tr>
                      <tr>
                        <td align="right" class="form-title">EMAIL</td>
                        <td>&nbsp;</td>
                        <td width="202" height="40"><input name="email" type="text" class="textfield" id="textfield2" size="30" /></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td width="202" valign="bottom" id="form-box"><table width="202" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="65" valign="top"><input type="image" name="button" id="button" src="<?php get_theme_url(); ?>/images/buttons/send.png" alt="SEND" /></td>
                            <td width="137" valign="middle" class="error"><?php print $status; ?></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table>
                  </form>