Website contact form

I have a form on a website that has been in use for just over a year. The owner of the site just informed me that the form no longer includes the subject when it gets emailed to him, everything else works just fine. He does not know how long this has been going on either. I looked at the sendmessage.php file to see if it had been edited, it had not been touched since I uploaded it last September. The only thing I can think is that a setting in PHP is blocking the mail subject from being sent through. Below I have copied the code from the sendmessage.php as well as the code for the form on the page. Any help is greatly appreciated.

Oh, server config is as follows:
cPanel Version 11.52.0 (build 21)
Theme paper_lantern
Apache Version 2.2.27
PHP Version 5.3.27
MySQL Version 5.5.46-cll
Architecture i686
Operating System linux
Shared IP Address ******
Path to Sendmail /usr/sbin/sendmail
Path to Perl /usr/bin/perl
Perl Version 5.10.1
Kernel Version 2.6.32-042stab094.7

sendmessage.php contents:

[php]<?php
$sendto = "[email protected]";

//new variables
$getconame = $_POST[‘coname’];
$getname = $_POST[‘username’];
$getcellphone = $_POST[‘cellphone’];
//end new variables
$usermail = $_POST[‘email’];
$content = nl2br($_POST[‘msg’]);
$getsubject = $_POST[‘subj’];

$subject = “”.$subj."";
$headers = "From: " . strip_tags($usermail) . “\r\n”;
$headers .= "Reply-To: ". strip_tags($usermail) . “\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html;charset=utf-8 \r\n”;

$msg = “”;
$msg .= "

\r\n";
$msg .= “

Sent by: “.$usermail.”

\r\n”;
//new fields

$msg .= “

Company: “.$getconame.”

”;
$msg .= “

Name: “.$getname.”

”;
$msg .= “

Email: “.$usermail.”

\r\n”;
$msg .= “

Cell #: “.$getcellphone.”

\r\n”;
$msg .= “

Message: “.$content.”

\r\n”;
$msg .= “”;

if(@mail($sendto, $subject, $msg, $headers)) {
echo “true”;
} else {
echo “false”;
}

?>
[/php]
form on website

<td align="right"><label for="subj">Subject&nbsp;</label></td>
<td><input type="subj" id="subj" name="subj" class="txt" value="SP2672 - 192' x 42' x 11.5' Spud Barge" style="background-color: white;"></td>
Company 
Name 
Cell phone 
E-mail 
						<label align="center" for="msg">Enter a Message</label>
						<textarea id="msg" name="msg" class="txtarea"></textarea>
						
						<button id="send">Send E-mail</button>
					</form>

I don’t know what you’re trying to do, but shouldn’t this
[php] $getsubject = $_POST[‘subj’];

$subject = “”.$subj."";[/php]

simply be
[php]$subject = $_POST[‘subj’];[/php]?

This is just a simple contact form that pops up in a Modal Box…I left all the code for the Modal Box out cause I thought it was irrelevant to the problem.

I did as suggested and removed the [php] $getsubject = $_POST[‘subj’];[/php] line. Did not fix the problem.

Might have found the issue browsing around the server settings.

These 2 items are in the WHM under ‘Basic cPanel & WHM Setup’

[hr]
An API Token for the Pushbullet API

The current value for this field is invalid. You must update it.
[hr]
A comma-separated list of http:// or https:// URLs of a system to which you want to send POST notifications as form data with the keys “hostname”, “subject”, and “body”. Query strings will be converted and sent as POST data. For example https://www.cpanel.net/events.cgi?apikey=XXXXX will send apikey via POST. Note that all keys and values must be in URLencoded format. Also, if you use the http://user:[email protected]/ format to authenticate to the destination system, you must also URLencode the “user” and “password” keys and values.
[hr]

I haven’t had time to look into these yet so if anyone can let me know what should be in these two boxes it would save me a great deal of time.

Thanks in advance!

[php] if(@mail($sendto, $subject /* Notice the variable name */, $msg, $headers)) {
echo “true”;
} else {
echo “false”;
}[/php]

It can’t be
[php]$getsubject = $_POST[‘subj’];[/php]

it needs to be
[php]$subject = $_POST[‘subj’];[/php]

I just notice you have @ in front of mail that suppresses errors, get rid of @.

That fixed it. See what an extra set of eyes can do for you. Thanks a lot Strider64!

Sponsor our Newsletter | Privacy Policy | Terms of Service