August 24, 201213 yr Hi, I don't know much of php and i have a form on my website that, for now, sends its content like this: " topic of the text-area : content of the text area " i would like the mail to look more like this: " topic of the text-area: content of the text area " and i think the code part is this one : if ($mField->type == '1') { print '<textarea class="rapid_contact_ex textarea ' . $mod_class_suffix . '" name="'.$form_id.'rpx_'.$field_name.'" cols="' . $t_cols . '" rows="' . $t_rows . '">'; if (isset($_POST[$form_id."rpx_".$field_name])) { print $_POST[$form_id."rpx_".$field_name]; } else { print JText::_($mField->default); } print '</textarea>'."\n"; } i played with "\n" or nl2br() but in vain, i can't manage to get what i want. could you please help me with this? thanks a lot !
August 24, 201213 yr Windows server? Give \r\n a go instead of \n. eg: first line\r\nsecond line should produce... first line second line On *nix servers \n should so the job.
August 24, 201213 yr Author and how do i check which is first line and which is second? i know i didn't give much code, but i'm really not into php... i can give more code if you want me to?
August 24, 201213 yr Your topic title says email so look for the mail function which could look something like this:- mail( $admin, "Feedback: $subject", "$name\r\n$email\r\n$message\r\n$component $size\r\n$delivery\r\n$confirmation", "From: $name <$admin>" ); where the \r\n should make a line break.
August 24, 201213 yr Nope, $_POST is a special variable which holds any data posted to the page, it's unrelated to the mail() function (in fact it's not even a function!). The mail() function works like this: $to = "myaddress@mydomain.com"; $subject = "automatic email from my website"; $message = "This is the first line of the email body, \r\n this is the second line."; mail( $to , $subject , $message ); There's more to it than that, you need to check for tampered headers and so on if there's any user input going on. Oh, and to keep your server admin/owner happy please don't call it mailform.php ! There are lots of automated bots that trawl through websites looking for mailform.php and similar names, and then scanning them for vulnerabilities. A surprising amount of spam is sent through this route.
August 24, 201213 yr Actually, my reference to the mail function may be misleading. Are you extracting from a database to display in rows in the email and want items from one database field to be displayed with a line break? That may need different help and perhaps the database entry needs a line break inserted in the field, or are "topic of the text-area:" and "content of the text area" in separate dabase fields?
Create an account or sign in to comment