Jump to content

this form has problems


robber2
 Share

Recommended Posts

http://perfectionconstruction.com/LuthaZar...m_practice.html someday i will have to get a form working, so this page is just a stupid test, but it has all the elements i might need to use, mostly copied and pasted from an online tutorial, some modifications to get it to validate. Here's the issue(s): It validates only if you remove the wrap="physical" part (I'd be interested in knowing why it doesn't like that attribute). It doesn't like a select multiple, like where the music tastes part is, it causes all kinds of errors. I don't know why, so I just took it out, now you'll only have one choice. I know the mailto link is frowned upon, and i've been trying to learn PHP, but I haven't found a slick way to have PHP email me the contents of the form. Maybe i haven't looked hard enough. The mailto thing doesn't seem to work well at all. FF adds a subject line and sends one long line of fairly unreadable junk. IE6 sends an attachement (.att) that can't open, Safari sends only the name field. I'm kinda lost here, but i'd welcome any help along these lines. Thx.
Link to comment
Share on other sites

Never heard of wrap="phyical" so I couldn't tell you anything about it. But, from the looks of it, the validator doesn't like it, so it's either a deprecated attribute or just made up. I would suggest just leaving it off.

Link to comment
Share on other sites

There is no such attribute called "wrap", there are CSS properties to control word wrapping if you want to though.This is how you make a multiple select:<select name="music" size="4" multiple="multiple">I'm not sure what you define as a "slick" way to send an email, but if you do a Google search for PHP email scripts you should find several. All of them use this function:http://www.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

There is no such attribute called "wrap",Here's where i was misinformed:http://www.tizag.com/phpT/examples/formex.phpread down to the textarea paragraph.multiple="multiple"i should have known that... thanksAlso thanks for the obvious ref to php.net, again, should've looked before I asked! I appreciate the feedback.Why does the mailto link get so much bad publicity (other than it seems to not work...)?

Link to comment
Share on other sites

Why does the mailto link get so much bad publicity (other than it seems to not work...)?
Because it is clumsy, inefficient and is client-dependant, as it has to open up the client's email software to send the message. A backend solution such as using PHP is silent, fast and is entirely performed server-side. Plus, you can format the message any way you want, instead of having to receive the mesasge as a post string.
Link to comment
Share on other sites

well, then!i guess that answers that. i'm currently working the php thing. never done any programming, and it's a challenge, but all i want to do for today is send the contents of a form via php email. i totally get the php.net info from above post, but i'm still unsure how to ALSO send other form data besides message and subject.

Link to comment
Share on other sites

I'm not sure what the guy was thinking when he wrote this:

In reality, textareas are oversized input fields. Treat them the same way, just be aware of the wrap attribute and how each type of wrap will turn out. PHP relys on this attribute to display the textarea.
Here is the HTML 4.01 spec for textarea, the attribute list doesn't include a "wrap":http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.7Also, he says PHP relies on the wrap attribute to display the textarea.. well, PHP doesn't display the textarea at all, the web browser does. PHP is not aware of any HTML elements on the page or what their attributes are. So I can see how you got confused.Everything you want to send in the mail goes in the body, in the email text. This is the example on the mail reference page with an extra part to build the body text:
<?php$to	  = 'nobody@example.com';$subject = 'the subject';$message = "Feedback from web page:\n";$message .= "name: {$_POST['name']}\n";$message .= "comments: {$_POST['comments']}\n";$headers = 'From: webmaster@example.com' . "\r\n" .	'Reply-To: webmaster@example.com' . "\r\n" .	'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?>

Link to comment
Share on other sites

http://www.perfectionconstruction.com/Luth.../test/mail3.phpThe two problems I have now are:1) The lines don't break. The message, name and comments are all on the same line in the email I receive.2) If you use apostrophes in the subject, message or comments, they show up in the email like this: "It\'s a boy\'s life."What am I missing here?Also, any other observations/advice is certainly welcomed.
<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $email = $_REQUEST['email'];  $subject = $_REQUEST['subject'];  $message = "{$_REQUEST['message']}\n";  $message .= "name: {$_REQUEST['name']}\n";  $message .= "comments: {$_REQUEST['comments']}\n";// To send HTML mail, the Content-type header must be set$headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers .= "From: $email";  mail( "robazar@earthlink.net", "Subject: $subject",  $message, $headers);  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  echo "<form method='post' action='mail3.php'>  Email: <input name='email' type='text' /><br />  Name: <input name='name' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='10' cols='40'>  </textarea><br />  Comments:<br />  <textarea name='comments' rows='10' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?>

Link to comment
Share on other sites

You're sending the content-type header to make the email HTML format instead of plain text. The \n is a plain text linebreak, but if you want to use HTML format then you need to use <br> for an HTML line break.To remove the extra slashes, you can use the stripslashes function.$msg = stripslashes($_POST['message']);

Link to comment
Share on other sites

First, thx for the help so far. Be patient, I'm really working this but I'm obviously still confused Here's my re-code, and it's feeling like a mess. I know there's a more streamlined way to do this, maybe add the stripslashes function to the REQUEST as a string?

<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $email = $_REQUEST['email'];  $subject = $_REQUEST['subject'];  $subject = stripslashes($_POST['subject']);  $message = "message: {$_REQUEST['message']}<br />";  $message = stripslashes($_POST['message']);  $message .= "name: {$_REQUEST['name']}<br />";  $message .= stripslashes($_POST['name']);  $message .= "comments: {$_REQUEST['comments']}<br />";  $message .= stripslashes($_POST['comments']);// To send HTML mail, the Content-type header must be set$headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers .= "From: $email";  mail( "robazar@earthlink.net", "Subject: $subject",  $message, $headers);  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  echo "<form method='post' action='mail3.php'>  Email: <input name='email' type='text' /><br />  Name: <input name='name' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='10' cols='40'>  </textarea><br />  Comments:<br />  <textarea name='comments' rows='10' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?>

Here's what I get:Hope you're likin' it.name: Doggy\'s dogDoggy's dogcomments: Didn\'t think you did.Didn't think you did.

Link to comment
Share on other sites

You're duplicating everything: $message = "message: {$_REQUEST['message']}<br />"; $message = stripslashes($_POST['message']); $message .= "name: {$_REQUEST['name']}<br />"; $message .= stripslashes($_POST['name']); $message .= "comments: {$_REQUEST['comments']}<br />"; $message .= stripslashes($_POST['comments']);You add everything twice, once with slashes and once without.

Link to comment
Share on other sites

I think I got it. I had to bang my head repeatedly, but this code is doing what I want it to. Thanks for all the help. My new motto: "concatenate like crazy!"Any further advice, comment, or crit is MOST welcomed!

<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $email = $_REQUEST['email'];   $subject = stripslashes($_POST['subject']);	  $message = "Name:		" . stripslashes($_POST['name']) . "<br />";  $message .= "Email:	   " . stripslashes($_POST['email']) . "<br />";  $message .= "Message:	 " . stripslashes($_POST['message']) . "<br />";    $message .= "Comments:	" . stripslashes($_POST['comments']) . "<br />";  // To send HTML mail, the Content-type header must be set$headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers .= "From: $email";  mail( "robazar@earthlink.net", "Subject: $subject",  $message, $headers);  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  echo "<form method='post' action='mail3.php'>  Email: <input name='email' type='text' /><br />  Name: <input name='name' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='10' cols='40'>  </textarea><br />  Comments:<br />  <textarea name='comments' rows='10' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...