Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Changing Headers In Php Contact Form

Featured Replies

Hey,

 

I was given a standard php contact form, and as ive been learning ive been trying to customise for my needs. Now, what i want to do is change the headers (so for example, instead of saying from Apache, it says from the Sales Team) on the email that the mail function sends. I read a tutortial on it, but im getting errors when im testing it out. Id really appreciate it if you could have a look over it.

 

<!--Contact Form Code Start-->

<?php

fixed now

<!--Contact Form Code End-->

 

Thanks for any help

It's because you're using unescaped quotes. $body (line 59) and $their_body (line 66) both are double quoted strings where you have unescaped double quotes inside.

 

When you use large chunks of text like that I'd suggest you use a heredoc string. http://no.php.net/types.string#language.ty....syntax.heredoc

 

By the way? What editor do you use? Plain text notepad? When I viewed the code in PHP Edit which colours the code I spotted the problem right away. PHPEdit also immediately highlighted the syntax error for me.

  • Author
It's because you're using unescaped quotes. $body (line 59) and $their_body (line 66) both are double quoted strings where you have unescaped double quotes inside.

 

When you use large chunks of text like that I'd suggest you use a heredoc string. http://no.php.net/types.string#language.ty....syntax.heredoc

 

By the way? What editor do you use? Plain text notepad? When I viewed the code in PHP Edit which colours the code I spotted the problem right away. PHPEdit also immediately highlighted the syntax error for me.

Thanks a lot for the reply. I got it now.

 

I was just using notepad, but ive downloade Notepad++ and find it much easier now.

 

I would like to know why the code below works though. Is it becuase it is a single quote mark, so you dont have to escape the double quote marks of the "center"? In that case wouldnt it be easier to always use since quote marks? Or do you have to use single some times, and double others?

I would like to know why the code below works though. Is it becuase it is a single quote mark, so you dont have to escape the double quote marks of the "center"? In that case wouldnt it be easier to always use since quote marks? Or do you have to use single some times, and double others?

 

Exactly, you don't need to escape the double quotes when the string is inside single quotes.

Apparently single quotes are faster for simple strings. Don't know how true that is.

Somebody please put me right.

 

Also your form layout isn't displaying correct in Firefox.

Forget that last comment, it seems to be displaying ok now.

Did you change it or am I seeing things? :unsure:

  • Author

OK, i think ill stick to single quotes then - much less hassle! But im sure theres a reason why people use double quotes, i mean why go through all the hassle of escaping when you could just use single quotes, unless theres a reason im not seeing.

 

Yeah, im having troubles with the menu bar. Im assuming your running Firefox 2?

Exactly, you don't need to escape the double quotes when the string is inside single quotes.

Apparently single quotes are faster for simple strings. Don't know how true that is.

Somebody please put me right.

 

Also your form layout isn't displaying correct in Firefox.

 

 

Single quoted strings are literal strings. The only special characters is the \' to escape single quotes.

 

Double quoted strings let you put variables inside it and add characters like \n \t etc to represent linebreaks and tabs. Due to this they are slightly slower. Heredocs works the same, except that it spans over multiple lines.

 

So unless you use variables or special characters, use single quoted strings.

Just a quick example:

 

var $var = 'world';
var $foo = "Hello $var \n This is second line";

This will outout

Hello world

This is second line

 

 

var $var = 'world';
var $foo = 'Hello $var \n This is second line';

This will outout

Hello $var \n This is second line

 

As you can see, single and double quoted strings got different purposes.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.