<html>
<head>
<title>Week #6 BASIC ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>

<body>
<?
/*
$mydomain = "http://www.timslan.com/scriptskewl/index.html";
if(eregi("$mydomain", $HTTP_REFERER)) { 
      // this visitor has come from my domain, so process the form

   } else {  
     // this visitor has NOT come from my domain, so do NOT process the form
     print("Sorry you can't use this page<br><br>You must come through the <a href=\"http://www.timslan.com/scriptskewl/index.html\">index</a> page.<br><br>
              </body></html>");
     exit();
}
*/
?>




<?

// When button is pushed:
if($_POST['button'] == "push"){

// Assign form entry variables a name
$recipient_name $_REQUEST['recipient_name'];
$recipient $_REQUEST['recipient_email'];
$from $_REQUEST['sender_name'];
$from_email $_REQUEST['sender_email'];
$breakfast $_REQUEST['breakfast'];
$lunch $_REQUEST['lunch'];
$subject "Some information from $from";
$body_of_email =" Hello $recipient_name, it is $from 's wishes that you recieve this information.
Today I had $breakfast for breakfast.
I will be eating lunch at $lunch. 

Thought I would let you know $recipient_name

Have a day,
$from"
;
$additional_headers "From: $from\n";


    
// Check Sender Email Syntax
       
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)"$from_email)){ 

           
// Proceed to check recipient email syntax
              
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)"$recipient)){ 

                 
// If the Sender email is good then - Send the mail
                    //if(mail($recipient, $subject, $body_of_email, $additional_headers)){
                    
print("Thank you $from, your mail has been sent to $recipient</body></html>");
                    exit();
                    
//}

              
}else{       
           
// If Recipient address is bad - bail out
              
print("<strong>The Syntax, <font color = 'Red'>$recipient</font>, is bad. Mail Not Sent</strong>");
              }

       }else{
    
// If Sender address is bad - bail out
       
print("<strong>The Syntax, <font color = 'Red'>$from_email</font>, is bad. Mail Not Sent</strong>");
       }
             
    }
?>

<h4>Fill out this form to have the results sent to someone via email.</h4>

<form method=POST action="<? $PHP_SELF?>">
<input type="hidden" name="button" value="push">
<table border="0">
<tr>
    <td><table border="0">
            <tr>
                <td align="right">To: <input type="text" name="recipient_name" size="10"></td>
                <td align="right">Recipients email Address:<input type="text" name="recipient_email" size="20"></td>
             </tr>
             <tr>
                <td align="right">From: <input type="text" name="sender_name" size="10"></td>
                <td align="right">Senders email Address:<input type="text" name="sender_email" size="20"></td>
             </tr>
       </table>
     </td>
</tr>
<tr>
    <td align="center">What you ate for breakfast: <input type="text" name="breakfast" size="15"><br>
                                   What time you will eat lunch: <input type="text" name="lunch" size="15"></td>
</tr>
<tr>
    <td align="center"><input type="submit" value="Submit Results"><input type ="reset" value="reset"></td>
</tr>
</table><br><clear="left">

</form>





<pre>
</pre>
<br>
<iframe src='wk6basicsrc.php' width='100%' height='300'></iframe>
<br>

<a href='../index.html'>BACK</a>

</body>
</html>