Hidden Email Field

liunx

Guest
hello all,

as of now my email address is shown in the form (i am the "to")

i would like to make it so that the viewer can not see it (hidden).

i have not been able to figure out how to do this.

any help will be much appreciated.


mailform.php

<form action="mail.php" method="POST" enctype="multipart/form-data">

<p>To: <input type="text" name="to" size="30" value="[email protected] " /><br />

From: <input type="text" name="from" size="30" value="" /><br />

Subject: <input type="text" name="subject" size="30" value="" /></p>

<p>Message:<br />

<textarea cols="70" rows="20" name="message"></textarea></p>

<p>File Attachment: <input type="file" name="fileatt" size="30" /></p>

<p><input type="submit" value="Send" /></p>

</form



mail.php

<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];

// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}

// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Mail sent to ImportRival! Thank You!</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>Just replace this bit of HTML:

<p>To: <input type="text" name="to" size="30" value="[email protected] " /><br />

with:

<input type="hidden" name="to" value="[email protected]">


just a matter of opinion - but i don't think it is good practice to put <BR> tags inside a <P> (have read it is not recommended in the HTML spec)Don't want to get too technical here but the <br> tag is classed as an inline tag and permitted to follow any block-level element. For a more technical interpretation see below

<!ENTITY % special
"A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">

<!-- %inline; covers inline or "text-level" elements -->
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">

<!ELEMENT P - O (%inline;)* -- paragraph -->
The entity special refers to a number of elements, one of which is the <br> one.

The entity inline refers to any parsable data (PCDATA), elements defined in various entities, including special (which, if you remember, contains the <br> element).

Finally, looking at the document definition for the <p> element shows that it can be followed by any element which is defined in the inline entity, which indirectly means a <br> tag.

Therefore it is valid for a <br> tag to follow a <p> tag.

Hope this helps.I stand corrected.

But if I find my source, I'll let you know.Sure, by all means do.

It can often be a confusing subject (which elements can be nested in what?), I learnt to ignore pretty much all the tutorials and rely on what the W3C specifications say. Unfortunately the specifications are written in something called SGML which in itself is quite complex. As such I spent some time learning the bits of SGML I needed to in order to understand the specifications.

At the end of the day, it is quite confusing but learning how to read the spec really helps when trying to produce HTML 4.01 or XHTML 1.0 compliant pages.yeah, i'm chugging through the W3C HTML 4.01 Spec at the moment - learning a few neat things from it that I never would have gotten from the book I have at home.Originally posted by torrent
Don't want to get too technical here but the <br> tag is classed as an inline tag and permitted to follow any block-level element. For a more technical interpretation see below

but does that count when the <p> is never closed? like above. I think tha tis what horus is on too. since the <p> is never closed does it still validate as followingYes it does still validate.

The reason is that the rules for which tags follow which are determined in the HTML 4.01 specification. The HTML 4.01 SGML is unconcerned with closing tags for some elements (and in fact the O you see in the P element's definition states the closing tag as optional).

Closing tags become important when you are coding to adhere to the XHTML standard. The XHTML specification does not redefine any HTML tags, it simply applies well-formed-XML rules the 4.01 specification.and in fact the O you see in the P element's definition states the closing tag as optional
hehe than that kind of goes against this thread :P

<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=24789Well">http://www.htmlforums.com/showthread.ph ... =24789Well</a><!-- m --> it doesn't really go too much against that thread because the general concensus was that you should always close your tags as it is good practice, and this is correct.

However, it is not illegal for some tags to not be closed if you are only making your pages HTML 4.01 compliant. It is however, illegal for any tag to not have a corresponding closing tag (or a self-closing tag) when coding to the XHTML standard.Example Valid HTML 4.01 File:

Here you see a file with one open <p> and one <p> with a closing </p> tag. Both include the <br> tag. When parsed by the HTML Validator at W3C org (<!-- m --><a class="postlink" href="http://validator.w3.org/">http://validator.w3.org/</a><!-- m -->) the document validates. It will not validate if you feed it through the XHTML parser, even if you change the DTD to be the correct one for XHTML.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>This is a<br>valid HTML 4.01 document!
<p>Call me Susan<br>if it ain't so!</p>
</body>
</html>thank you SO much!!!well, I guess you're not Susan ;)

but there is a difference still between good code and good practice.

I personally feel better closing all elements that have closing tags - optional or mandatory.

It makes code easier to read, and therefore easier to go back to and change.Yup, won't hear me disagreeing with that statement, although allowing the <br> after a <p> tag is still good coding.
 
Back
Top