Posting contact form to variable email address PHP

Hi all, another one!
I want the email address to be the hidden variable in the form below - variable higlighted in Red. What would I put for "$to ="?
Any help would be appreciated.
Tom
<?php
if (array_key_exists('send' , $_POST)) {
          // mail processing script
          // remove escape characters from POST array
if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
  function stripslashes_deep($value) {
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
  $_POST = array_map('stripslashes_deep', $_POST);
$to = '';
          $subject = '';
          //list expected fields
          $expected = array('name', 'email', 'comments');
          //set required fields
          $required = array('name', 'comments');
          //create empty array for any missing fields
          $missing = array();
          // assume that there is nothing suspect
          $suspect = false;
          // create a pattern to locate suspect phrases
          $pattern = '/Content-Type:|Bcc:|Cc:/i';
            // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
          // and pass it recursively back to the same function
          if (is_array($val)) {
      foreach ($val as $item) {
              isSuspect($item, $pattern, $suspect);
            } else {
      // if one of the suspect phrases is found, set Boolean to true
            if (preg_match($pattern, $val)) {
        $suspect = true;
          // check  the $_POST array and any subarrays for suspect content
          isSuspect($_POST, $pattern, $suspect);
          if ($suspect) {
                    $mailSent = false;
                    unset($missing);
          } else {
          //proces the $_POST Variables
          foreach ($_POST as $key => $value) {
                    //assign temporary variable and strip whitespace if not an array
                    $temp = is_array($value) ? $value: trim($value);
                    //if empty and required, add to $missing array
                    if (empty($temp) && in_array($key, $required)) {
                              array_push($missing, $key);
                    } elseif (in_array($key, $expected)) {
                              //otherwise, assign to a variable of the same name as $key
                              ${$key} = $temp;
          // validate the email address
  if (!empty($email)) {
    // regex to identify illegal characters in email address
    $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
          // reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)) {
      $suspect = true;
      $mailSent = false;
      unset($missing);
          //go ahead ONLY if not suspect and all required fields OK
          if (!$suspect && empty($missing)) {
          // build the message
          $message = "Name: $name\r\n\r\n";
          $message .= "Email: $email\r\n\r\n";
          $message .= "Message: $comments\r\n\r\n";
          //limit line length to 70 characters
          $message = wordwrap($message, 70);
          //Create aditional headers
          $headers = "From: Website Enquiry\r\n";
          $headers .= 'Content-Type: text/plain; charset=utf-8';
          if (!empty($email)) {
          $headers .= "\r\nReply-To: $email";
          //send it
          $mailSent = mail($to, $subject, $message, $headers);
          if ($mailSent) {
                    //$missing is no longer needed if the email is sent, so unset it
                    unset($missing);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
if ($_POST && $mailSent) { ?>
<META HTTP-EQUIV="Refresh" CONTENT="5;URL=index.php">
<?php } ?>
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-11804201-5']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
</script>
</head>
<body<?php if ($_POST && $mailSent){ ?> onLoad="redirect()"<?php } ?>>
<img src="images/photography/background.jpg" alt="Jack Wilesmith Furniture Design" class="bg" id="bg" />
<div id="container">
  <div id="Header">
  </div>
  <div id="content">
<?php
if ($_POST && isset($missing) && !empty($missing)) {
          ?>
    <p class="warning"><strong>Please complete the missing item(s) indicated.</strong></p><br />
    <?php
} elseif ($_POST && !$mailSent) {
          ?>
    <p class="warning"><strong>Sorry, there was a problem sending your message, please try again later. </strong></p><br />
          <?php
} elseif ($_POST && $mailSent) {
          ?>
    <p><strong>Your Message has been sent succesfully - <strong>You will be redirected in 5 seconds</strong></strong></p><br />
<SCRIPT LANGUAGE="JavaScript"><!--
function redirect () { setTimeout("go_now()",5000); }
function go_now ()   { window.location.href = "index.php"; }
//--></SCRIPT>
    <?php } ?>
    <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p>
      <label for="name">Name:</label><br />
      <input name="name" type="text" class="textInput" id="name"
      <?php if (isset($missing)) {
echo 'value="' . htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8') . '"';
?>
      /> <?php
            if (isset($missing) && in_array('name', $missing)) {?> <span class="warning">Please enter your name</span><?php } ?>
    </p><br />
    <p>
      <label for="email">Email:</label><br />
      <span id="sprytextfield1">
      <input name="email" type="text" class="textInput" id="email"
      <?php if (isset($missing)) {
echo 'value="' . htmlentities($_POST['email'], ENT_COMPAT, 'UTF-8') . '"';
?>
      />
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
      <?php
            if (isset($missing) && in_array('email', $missing)) {?> <span class="warning">Please enter your Email Address</span><?php } ?>
    </p><br />
    <legend></legend>
    <p>
      <label for="comments">Message:</label><br />
      <textarea name="comments" id="comments" cols="45" rows="5"><?php if (isset($missing)) {
                    echo htmlentities($_POST['comments'], ENT_COMPAT, 'UTF-8');
            } ?></textarea><?php
            if (isset($missing) && in_array('comments', $missing)) {?> <span class="warning">Please enter a Message</span><?php } ?>
    </p><br />
    <p class="clearIt">
      <input name="send" type="submit" id="send" value="Send message" />
    </p>
     <input name="email" type="hidden" id="email" value="[email protected]" />
</form>
</div>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {isRequired:false, hint:"[email protected]"});
//-->
</script>
</body>
</html>

Lovely, simple but beautiful!
Thanks for that.
T

Similar Messages

  • I can't move my contacts ( phone numbers and email addresses) from outlook express to my 8900 phone

    i can't move my contacts ( phone numbers and email addresses) from outlook express to my 8900 new phone through the usb cable.
    i have the same contacts in both outlook and outlook express, can this help.
    can anybody help

    highland_ddmac wrote:
    I have the 8900 and when I try and synch I get the error "unable to read application data". Very, very annoying.
    Wondering why I switched from Nokia!
    Can anyone help please??
    Hi and Welcome to the Forums!
    A lot more detail is needed to understand your issue...for instance:
    Your specific BB Model
    Your specific BB OS (all 4 octets)
    Your DTM version (again, 4 octets)
    Your PC PIM version
    Your PC OS version
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • When printing a list in Address Book, how can I select more than the default Attributes and keep them selected when I print again? I want to print ALL information for contacts so I have email address, notes, phone, company, title, etc all on one page.

    When printing a list in Address Book, how can I select more than the default Attributes and keep them selected when I print again? I want to print ALL information for contacts so I have email address, notes, phone, company, title, etc all on one page. I don't want to have to check off an additional 5 or 6 attributes each time I print out contact information. Is there a way to change the default setting for printing lists, so it is not just "phone," "photo," and "job title?"

    I have a user who wants to do this same thing. I did not find any way either to default the attributes to anything other than what you see the first time. Seems like such a trivial thing, hard to believe they do not allow it. I did find a program for this called iDress but I can't seem to download it from any links on the Internet. Not sure if it is free or not, but it was recommended by a link on the Mac support site.

  • How can I create a contact form for sending emails in SharePoint Online?

    Dear Forum members,
    I´ve got a question about creating a custom contact form to send emails for a public site in SharePoint online.
    Could someone help us with some advise?
    In advance, thank you very much.
    Kind regards,
    Frits

    You can create Custom list and make alerts enable to send emails as soon as contact created.
    Bala

  • HT4623 in settings and then general i do not have the option of software update...? How do I know if I am on IOS6 I also seem to be having trouble trying to use icloud i think this is because my apple id is not in the form of an email address...? can anyo

    in settings and then general i do not have the option of software update...? How do I know if I am on IOS6 I also seem to be having trouble trying to use icloud i think this is because my apple id is not in the form of an email address...? can anyone help

    stell80 wrote:
    in settings and then general i do not have the option of software update...?
    That is only present if you have already updated to iOS 5 or later.  If you're on iOS 4 you can only update while connected to your computer's iTunes.
    stell80 wrote:
    How do I know if I am on IOS6
    Settings/ General/ About
    stell80 wrote:
    I also seem to be having trouble trying to use icloud i think this is because my apple id is not in the form of an email address...? can anyone help
    You can't access iCloud from your iPhone unless you're on iOS 5 or later.  Otherwise, refer to this article:
    http://support.apple.com/kb/HT4436

  • How do I make a submit button that sends the form to an email address?

    I can see how to link to an email which then opens up an email someone could attach the form to. But I do not see how to make a button that automatically sends the form to an email address. Can someone provide assistance? Thanks!

    I have the same question. You'd thing this would be a no brainer requirement for a form.

  • Regd the contact person fax and email address

    Hi,
    I am trying to get the contact persons fax and email address.The telephone # is available in KNVK table.but I don't see fax and email.Let me know how to get the details.
    also I see PRSNR in KNVK..What  is the purpose of peson number?
    thanks
    Suganya

    Take a look at the code below, Extract from KNVK and use the prsnr number to extract tel number and email address.
    * Use function & dept to extract KNVK data and person number
    SELECT parnr kunnr namev name1 abtnr anred pafkt parh1 parh2 parh3 parh4 parh5 pakn2 pakn3 pakn4 pakn5 prsnr
    FROM knvk
    INTO TABLE i_knvk
    WHERE kunnr = wa_vbak-kunnr.
    * Use person number to extract the fax no.
    IF i_knvk[] IS NOT INITIAL.
    SELECT persnumber fax_number
    FROM adcp
    INTO TABLE i_adcp
    FOR ALL ENTRIES IN i_knvk
    WHERE persnumber = i_knvk-prsnr.
    ENDIF.
    IF i_knvk[] IS NOT INITIAL.
    SELECT persnumber smtp_addr
    FROM adr6
    INTO TABLE i_adr6
    FOR ALL ENTRIES IN i_knvk
    WHERE persnumber = i_knvk-prsnr.
    ENDIF.

  • Several contacts have the same email address. How can I choose which contact name appears on the address line in Mail?

    Several contacts have the same email address. How can I choose which contact name appears on the address line in Mail?

    you can't really, but you might be able to filter them by message content into folders for each, or color them with tags

  • My iphone5 has been hacked, so every message I get in Outlook is addressed to a Fatima Quedas, who is on my list of contacts and has two email addresses, one on gmail and the other my own.  I deleted the contact.  What else should I do?

    My iphone5 has been hacked, so every message I get in Outlook is addressed to a Fatima Quedas, who is on my list of contacts and has two email addresses, one on gmail and the other my own.  I deleted the contact.  What else should I do?

    change your email passwords.

  • Can log into FaceTime it then asks what I want to use as contact so I select email address it says verifying then asks for apple if again and just keeps repeating the process

    Can log into FaceTime it then asks what I want to use as contact so I select email address it says verifying then asks for apple if again and just keeps repeating the process

    Hello Magsbingham
    You may find the troubleshooting steps in the article below helpful.
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    -Griff W.

  • My original apple id which i use for itunes is not in the form of an email address and because of that i cannot access the cloud, if i change my id how will it affect my itunes account

    My original apple id which i use for itunes is not in the form of an email address so i cannot access the cloud.  if i change my apple id will it affect my itunes account?

    Welcome to the Apple community.
    You can use your primary ID or your alternate ID to log into iCloud. If you aren't sure what these are, you can find out at...
    My Apple ID

  • Since update to 5.0.1 iphone contacts caller id shows email address rather than contact name and number

    Since i upgraded to 5.0.1 . My iphone contacts caller id shows email address not contact name and number. Is this a settings issue?

    Hi, it's maybe happening the same here!
    I have an iphone 3gs. Since I did the upgrade to ios5, when I receive an sms with the notification of a missed call I am no longer able to see if it's coming from a number of my contact list, because in the sms the message correspondence for that contact underlines now the number PLUS the first 2 cifres of the date! So the number results always being 2 numbers longer and it's impossible get to the original.
    That's really a major problem for me, as I'm no longer able to know who has called me, if someone I know (and who) or if a new number.
    I add a capture to explain it better (I have banned a couple of cifres for privacy reasons).
    Anyone solved the problem or can help please?
    Thank you!

  • HT204150 I linked my outlook express with icloud, not realizing it would change my outlook express contacts.  I deleted email addresses from my iphone which in turn deleted them from my PC.  Is there any way to get these addresses back?

    I linked my outlook express with icloud, not realizing it would change my outlook express contacts.  I deleted email addresses from my iphone, not wanting them there which in turn deleted them from my PC.  Is there any way to get these addresses back? Seems I no longer have an outlook contacts list.

    It's Outlook, not Outlook Express (different program) and if you have now deleted them from iCloud and do not have a backup they are gone.

  • DW CS5, Sending contact form results to email with page redirection using php script

    I am currently building a site from scratch with Dreamweaver, with the intent of replacing my current website layout that was designed using Intuit's website builder. My dreamweaver site is not online, but i have setup a local test server on my computer, using XAMPP, and i have an apache server with a MySQL database and a mercury mailserver running. I mention that in case it makes a difference in your answers. If necessary, I can include those settings, but that may be asking too much.
    I have an html contact form for users to schedule service appointments. I need the resulting actioned php file to do the following after submit is clicked: verify certain fields have been entered; prevent spammers or verify human visitors; send the form results to a (hidden from public view of any kind) email address; redirect user to a confirmation page, or an error page.
    I found the following code but being less than a newbie im not sure what needs to be changed, or if its even the right script i should be using:
    5 <?php
    6 $email = $_POST['email'];
    7 $mailto = '[email protected]';
    8 $mailsubj = 'You Have a Service Request';
    9 $url = '/MyLandingPage.html';
    10 $req = '0';
    11 $mailbody = "Results from form:\r\n";
    12 $space = ' ';
    13 $line = '
    14 ';
    15 foreach ($_POST as $key => $value)
    16 {
    17 if ($req == '1')
    18 {
    19 if ($value == '')
    20 {echo "$key is empty";die;}
    21 }
    22 $j = strlen($key);
    23 if ($j >= 20)
    24 {echo "Name of form element $key cannot be longer than 20 characters";die;}
    25 $j = 20 - $j;
    26 for ($i = 1; $i <= $j; $i++)
    27 {$space .= ' ';}
    28 $value = str_replace('\r\n', "$line", $value);
    29 $conc = "{$key}:$space{$value}$line";
    30 $text .= $conc;
    31 $space = ' ';
    32 }
    33 mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    34 echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    35 ?>
    Can anyone please illuminate me on what I need?
    Thank You in advance

    Take a read here, this might enlighten you a little.
    http://www.paulgdesigns.com/learncontactform.php
    You are doing this with your local testing server, is it set up to email?
    Gary

  • Submit completed form to multiple email addresses

    I am working with Acrobat 9 Pro and creating a pdf enquiry form to place on a website.
    I need the form when submitted to be sent to 4 email addresses so that it can be properly assessed. Each of those recipients needs to be able to add the response to a response file, so I need to 'distribute' the form.
    I can make is submit to multiple email addresses (having seen a previous post) by adding a submit button, enabling the extended features and not distributing. This is not a suitable solution, though, as it doesn't allow the recipient to add to the response file.
    Whatever I try, I can only get it to send to the single email address shown in 'Preferences', so I'm stumped. Obviously I can set up an autoforward from a single account to the others, but that seems a clunky way of doing what should be a simple task.

    There are a few ways to do this. 
    Set up E-mail Notifications and to enable the "Include submitted data" option.  (E-mail Notifications settings are in the Options tab)
    Share the responses by making the other person a Co-author, Contributor or Reader.  The differences in account levels are explained here.
    Share the repsonses by using Publish Responses feature.  This will allow you to send out a URL that will display the View Responses and/or the Summary Report to anyone that has your URL.  Further details are here.
    -Jeff

Maybe you are looking for