Thank you devinemke for your reply,
Yes as you said it is complicated but it is also what I need. Looking at your suggestion I went back to the manual and studied a bit more the array part.
Here is what I came with and it does work as long as action="" (no space)
<?php
$ids = sprintf($_SERVER['QUERY_STRING']);
/function to insert elements/
function addArray(&$array, $id, $var)
{
$tempArray = array( $var => $id);
$array = array_merge ($array, $tempArray);
}
/function to insert subarray/
function addArrayArr(&$array, $var, &$array1)
{
$tempArray = array($var => $array1);
$array = array_merge ($array, $tempArray);
}
/labels of our array for the headers/
$keyarr = array("name","email",);
/info that would be nice to read from a separate file/
$valarr0 = array('empty','empty',);
$valarr1 = array('First Name','first@domain.com',);
$valarr2 = array('Second Name','second@domain.com',);
$valarr3 = array('Third Name','third@domain.com',);
$valarr4 = array('Fourth Name','fourth@domain.com',);
/If read from a separate file should be easy to input automatically the number of lines/
$numofrows = 5;
/ now establishing the data/
$tmpArray = array();
for($i = 0; $i < $numofrows; $i++){
$tmp = "valarr$i";
$tmpvar = ${$tmp};
foreach( $keyarr as $key=>$value){
addArray($tmparr,$tmpvar[$key],$value);
}
addArrayArr($finalarr,$i,$tmparr);
if ($i == $ids){
$recname = (isset($recname) && $recname) ? $recname : $finalarr[$i]["name"];
$recmail = (isset($recmail) && $recmail) ? $recmail : $finalarr[$i]["email"];
}
}
$thanksmessage="Thank you! Your email has been sent, we will respond shortly."; //Your thank you message, displays after the email has been sent.
If($POST['submit']) {
extract($POST);
If ($yourname=="") {
$error = "1";
$error_text .= "You did not enter your name!<br />";
}
If ($youremail=="") {
$error = "1";
$error_text .= "You did not enter your email!<br />";
}
If($yoursubject=="") {
$error = "1";
$error_text .= "You did not enter your subject!<br />";
}
If ($youremail) {
If (!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)){
$error = "1";
$error_text .= "Invalid Email Address!<br />";
}
}
If ($yourmessage=="") {
$error = "1";
$error_text .= "You did not enter a message!<br />";
}
If($error=="1") {
$disperrors=$error_text;
} Else {
$headers = "From: ".$yourname." <".$youremail.">\n";
$headers .= "Reply-To: ".$yourname." <".$youremail.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$headers .= "X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers .= "X-Mailer: Sunnymead Mailer\n";
$headers .= "Return-Path: <".$recmail.">\n";
$message .= "\n";
$message .= "$yourmessage";
$message .= "\n";
If(!mail($recmail,$yoursubject,$yourmessage,$headers)) {
exit("There has been an error, please contact the admin");
}
Echo("<div align=\"center\">".$thanksmessage."</div>");
exit();
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<div align="center">
<?php Echo("<div align=\"center\"><b>".$disperrors."</b></div>"); ?>
<fieldset class="box" style="width: 80%;"><legend align="left"><span class="subtitle">contacting <?php Echo("$recname\n"); ?></span></legend>
<form action="" method="post">
<table border="0" cellspacing="2" cellpadding="2" align="center">
<tr><td>
<fieldset class="box"><legend align="left">From whom:</legend>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="100" align="right">Your name: </td>
<td><?php Echo("<input name=\"yourname\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".stripslashes($yourname)."\" />\n"); ?></td>
</tr>
<tr>
<td width="100" align="right">Your email: </td>
<td><?php Echo("<input name=\"youremail\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".stripslashes($youremail)."\" />\n"); ?></td>
</tr>
<tr>
<td width="100" align="right"> Subject: </td>
<td><?php Echo("<input name=\"yoursubject\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".stripslashes($yoursubject)."\" />\n"); ?></td>
</tr></table>
</fieldset>
</td></tr>
<tr> <td align="center" valign="top">
<fieldset class="box"><legend align="left">Your message</legend>
<?php Echo("<textarea name=\"yourmessage\" rows=\"6\" cols=\"50\" style=\"width: 400px;\">".stripslashes($yourmessage)."</textarea>\n"); ?>
</fieldset>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="submit" value="Send Email" class="input"> <input type="reset" name="reset" value="Reset Form" class="input"></td>
</tr>
</table>
</form>
</fieldset>
</div>
</body>
</html>
This does make a feedback form that I can call from anywhere without giving a name or an email address through a text link.
BUT, I still don't understand why the variables $rename or $recmail get empty if I use an action in the form statement. it would be nice if you or some one else could explain this to me.
Now, I tried to add a file attachement to this form and this loss of variables stops it from funtionning.
Other thing that I would like to learn would be to call the proper name and email address from an external file...
Please let me know how to keep those variables in memory as in the manual and example stated that this type of statement would make it GLOBAL as a $_POST statement.
Thanks again
Eric