Well here is try number three. Not sure this is a great practice of coding. But so far I have been on my own here.
This is the form processing code I have. It gives me back the last name in my external list. Or DB if you will.
Code:
<?php
$errmsg = ''; // error message
$line = '';
$email = ''; // sender's email addres
$question = ''; // question one
if(isset($_POST['send']))
{
//$firstname=($_POST['firstname'])?"$firstname: Yes":"$firstname: No";
$file = 'people.txt';
$lines = file($file);
foreach ($lines as $value => $line) {
$firstname = strtok($line, ' ');
//echo "$line";
//$line = ($_POST['name[]'])?"name[]: Yes":"name[]: No";
if ($_POST['name[]']=='y'){
echo "$line: Yes\n";
}
else{
echo "$line: No\n";
}
}
$email = $_POST['email'];
$question = $_POST['question'];
$subject = 'Constituency Employee Verification';
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "Content-Transfer-Encoding: 7bit\r\n";
$headers = "From: $email\r\n";
if(trim($email) == '')
{
$errmsg = 'Please enter your email address';
}
else if(!isEmail($email))
{
$errmsg = 'Your email address is not valid';
}
if($errmsg == '')
{
if(get_magic_quotes_gpc())
{
$question = stripslashes($question);
}
// the email will be sent here
$to = "yourname@email.com";
// the email subject ( modify it as you wish )
$subject = 'Results from Academic Services Technology Verification form' ;
// the mail message ( add any additional information if you want )
$msg = "Names = $line \n\nE-mail = $email \n\nAdditional Employees = $question \n\n ";
//$msg .="\n$firstname";
//mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
$mailsent = mail("$to,$email", $subject, $msg, $headers);
if (mailsent) {
echo "<h2>Thank you for filling out our form!</h2>";
echo "<h3>Your message has been sent!</h3>";
echo "<p>Please print the following for your records:</p>";
echo "<p><b>Subject:</b> $subject</p>";
echo "<p><b>Names:</b><br>$line<br></p>";
echo "<p><b>E-mail:</b><br>$email</p>";
echo "<p><b>Additional Employees:</b><br>";
echo "$question</p>";
} else {
echo "There was an error...";
}
?>
And here is what the dynamic checkbox code looks like.
Code:
$file = 'people.txt';
$lines = file($file);
foreach ($lines as $value => $line) {
$firstname = strtok($line, ' ');
echo "<input type='checkbox' name=\'names[]\' value=\'y\'> $line<br />\n";
}
That part is ok.
But I can't get more than one name from the list to come back to my e-mail. I am needing the whole list to come back.
Is there anyone who can help?
Bookmarks