The subsequent PHP works up to a point, that point being actually sending an e-mail that I receive. A reference was made "pointing" an HTML form at at. Right now, I have a "submit" button on an HTML form. That button uses "POST" to initiate "AutoEmail.php", and it works up to a point, that point being where it actually e-mails the data. Is there a workaround for this that permits me to retain the "submit" button and external "AutoEmail.php" text file approach? I don't want to start mingling PHP in the HTML generated by Publisher because I very much want to keep my approach to changing the HTML forms and the "front end" apppearance as clean and efficient as possible by using Publisher for all such changes.
Is this a matter of needing an HTML form in some "E-mail" format that contains the information of the "array" and the "body"? Is it feasible to tack such a form onto (or into) the following code without linking it to the web sites main index?
As for security, I realize that the big bad wolf could easily visit my web site and use the input fields to write some nasty code into the PHP that could do a great deal of damage, but I need to get the basics working first, even with security issues. I can only hope to later learn the "magic words" or logical structures that keep the wolf at bay by checking the inputs. More fundamentally, at present, I want to find a way to integrate a Publisher development front end into the use of PHP, with only a few exceptions in terms of the HTML files, such as this e-mail page (or pages) that might have to be crow-barred into the PHP code below, if that is possible. One other consideration is how I then integrate this e-mail page (or pages) that the PHP code fills out into the "index" page for the web site, or do I not need to do that, because it can stand-alone as a dead-end form loaded in a separate browser window on top of the calling, indexed page? (I hope I'm making sense here, this is a brand new area to me.)
NOT eliminating Publisher is a high priority in terms of my web site development effort. A few, simple HTML code fragements to produce specialized pages that I can keep in text files in a special directory are not a big deal, particularly if I know how to intermingle PHP and HTML, I just don' t want to disrupt my ability to use Publisher to update or change pages later by directly inserting PHP into the HTML generated by Publisher. I want the PHP in separate text files.
The problem of intermingling PHP in HTML generated after a page has been designed in Publisher shouldn't arise if I'm only calling text files that lead to dead end pages, like an e-mail form, that are loaded in addition to the last form that is navigable from the index and controlled from a form that is navigable from the index. It seems I need to find a way to introduce creation of a web page on which the various defined fields and e-mail text body can appear, but I don't know how to do that from within php in a text file, unless I should simply alternate between php and HTML, but then I don't know how to generate the HTML without creating a form in Publisher, then generating the HTML, which is possible if I create fields with names corresponding to "body", "name", "e-mail", "subject", "header", but Publisher will then automatically link it to the index page (making it browsable by the user). (Note that it appears that I would need two pages, each sent via e-mail to two different people with different content, per the intent of the following code.) I would also need to call each of the two new pages up before filling in the fields and the body (or so it would seem).
Thank you in advance to anyone who can take a few minutes to answer these questions. This seems to be responding in a manner that does get data from the two fields ('Email' and 'Name').
<?php
$to = $REQUEST['Email'] ;
$from = $REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@YourCompany.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
if($to == '') {print "You have not entered an Email, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://freeprohost.com/testproject/page6.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>