zero-perfoliate
zero-perfoliate

Author Topic: Blank Line between fields?  (Read 401 times)

Offline HawkMan

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
Blank Line between fields?
« on: February 24, 2010, 09:38:10 AM »
Below is a link to a tutorial on how to submit the fields in a form in an email.  I have gotten the script to work (FormToEmail.php) but it is putting a blank line between the fields. 

http://dreamweaverspot.com/adobe-dreamweaver-tutorial-contact-forms/

Example:

First Name: Joe

Last Name : Thomas

Address: 123 Anywhere Street

I want to change the code so that it doesn't put the blank line in between each field.

First Name: Joe
Last Name: Thomas
Address: 123 Anywhere Street

Can someone tell me how to do that, I have looked at the code and I am teaching myself PHP, but I can't figure it out.

Thanks,
Fred

hotnoob

  • Guest
Re: Blank Line between fields?
« Reply #1 on: February 24, 2010, 05:18:54 PM »
ok, im not sure what you are talking about...

but i think you are asking how to make the html fields without double line.

Simply remove one
 tag from each of the lines.

this should turn the tutorial code into what you want.
Code: [Select]
<form action="FormtoEmail.php" method=post name=ContactForm>
    <label>Name:</label><input type=text id=name name=name>
    <br /><label>Email:</label><input type=text id=email name=email>
    <label>Comments:</label>
    <textarea id=comments name=comments cols=50 rows=10></textarea>
    <br /><input type=submit name=submit value="Submit">
</form>

PS, who ever wrote that tutorial cant program worth sh!t.

Offline HawkMan

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
Re: Blank Line between fields?
« Reply #2 on: February 25, 2010, 12:34:10 PM »
No, I know how to take out a blank line on the form.  The FormToEmail.php code sends an email with all of the form fields and whatever was put in those fields.  I want to change the code in the php file so that when it sends the email, it doesn't put a blank line after each field.  If that doesn't make sense, let me know.  Here is the code that builds the email message.  This is the code that I want to change so it doesn't put a blank line after each field and the contents of the text field.

function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}


hotnoob

  • Guest
Re: Blank Line between fields?
« Reply #3 on: February 26, 2010, 02:20:20 PM »
ahhh... k

wow, who ever made that script... fails lol...
anyway...

Code: [Select]

function build_message($request_input)
{
if(!isset($message_output))
{
$message_output ="";
}
if(!is_array($request_input))
{
$message_output = $request_input;
}
else
{
foreach($request_input as $key => $value)
{
if(!empty($value))
{
if(!is_numeric($key))
{
$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;
}
else
{
$message_output .= build_message($value).", ";
}
}
}
}
//new changes here
return trim(rtrim($message_output,", "));

}

i think the trim function also removed dl white space...


hotnoob

  • Guest
Re: Blank Line between fields?
« Reply #4 on: February 26, 2010, 02:30:51 PM »
Actualy...

forget the trim thing... well its a good thing to have...
but all you have to do is change...

PHP_EOL.PHP_EOL
to
PHP_EOL

i just realized PHP_EOL is the constant for "\n"

lol...

Offline HawkMan

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
Re: Blank Line between fields?
« Reply #5 on: March 08, 2010, 03:01:47 AM »
I figured out the PHP_EOL thing and removed one and it worked.  Came back here and saw you suggested that, THANKS! 

It is working great now, but for some reason, when it sends the email, it is converting whatever is put in the text fields on the form to lower case.  Any idea on why it is doing that?  The actual form I am using converts everything to upper case but when it gets sent in the email by the PHP script, it converts everything to lower case.  I can't figure that one out.

 

zero-perfoliate