I have this task to setup an entry form and display and send an email from that same page.
I am kind of stuck, could anyone help.Here is teh code:
<?php
/**************************************
**************************************/
$submit = $POST['submit'];
$emailAddress = $POST['emailAddress'];
$comments = $_POST['comments'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$name = $_POST['name'];
$ssn=$_POST['ssn'];
$contact_recipient_id = $_POST['contact_recipient_id'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$option = $_POST['option'];
?>
<html>
<head>
<style type="text/css">
@import url(style.css);
</style>
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" width="650">
<tbody><tr>
<td width="40"> </td>
<td>
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form action="<?php echo $me;?>" method='post'>
<table class="info">
<tr><td> </td></tr><tr><td> </td></tr>
<tr><td>Title:</td><td><input type="radio" name="title" value="Mr"/>Mr
<input type="radio" name="title" value="Mrs"/>Mrs
<input type="radio" name="title" value="Miss"/>Miss</td></tr>
<tr><td id="fn">*First Name:</td><td><input type="text" name="fName" /></td></tr>
<tr><td id="ln">*Last Name:</td><td><input type="text" name="lName" /></td></tr>
<tr><td id="ss">*Social Security Number:</td><td><input type="text" name="ssn" size="9" maxlength="11"/></td></tr>
<tr><td id="ag">*Age:</td><td><input type="text" name="age" size="1" maxlength="3"/></td></tr>
<tr><td>Gender:</td><td><select name="gender">
<option value="male">M</option>
<option value="female">F</option>
</select></td></tr>
<tr><td id="ea">*Email Address:</td><td><input type="text" name="email" /></td></tr>
<tr><td id="pn">*Phone Number:</td><td><input type="text" name="phone" size="11" maxlength="13"/></td></tr>
<tr><td>Comments Or Questions:</td>
<td><textarea name="data" rows="4" cols="50"></textarea></td></tr>
<tr><td><input type="submit" value="Submit" name="submit"/>
<input type="reset" value="Reset" name="reset" /></td></tr>
<tr><td> </td></tr>
</table>
</form>
<?php
} else {
error_reporting(0);
$recipient = 'myemail';
$subject = 'Just to say Hi';
$from = stripslashes($_POST['fName']);
$msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Subject: $subject
Message:
$msg");
else
echo "Message failed to send";
}
?>
</body>
</html>
and how can i write those same info to a file:
I have this:
<?php
// Open and write to a file
$myFile = "testfile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$string = $name."\t"."\t".$ssn."\t".$email."\t".$subject."\t".$message."\n";
fwrite($fh, $string);
fclose($fh);
?>
Thanks for reading my post...