?
Solved

PHP Email Form Issues

Posted on 2014-02-07
11
Medium Priority
?
562 Views
Last Modified: 2014-02-07
I have a contact form on my website that is in php format. It has worked up until the last few months. Now when anyone submits the info on the form, regardless of what they enter, what receive is a blank form except for the email. See below for more info.

Our actual contact page is here: http://hcscomputersolutions.com/contact/contact.php

The code for the contact page is as follows:

<div id="form">
<h2>Send Us An Email</h2>
<p>If you are a client and have a technical problem or question please call or submit a work order through our client portal.</p>
<form action="emailProcessor.php" method="post">
<table>
<tr>
<td>Name:</td>
<td><input name="fullName" size="30" tabindex="1" type="text" /></td>
</tr>
<tr>
<td>Business Name:</td>
<td><input name="businessName" size="30" tabindex="2" type="text" />&nbsp;</td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input name="phoneNumber" size="30" tabindex="3" type="text" /></td>
</tr>
<tr>
<td>E-mail Address:</td>
<td><input name="emailAddress" size="30" tabindex="4" type="text" /></td>
</tr>
<tr>
<td>Preferred Method of Contact:</td>
<td>
<select name="contact" tabindex="5">
<option selected="selected">Phone</option>
<option>E-mail</option>
</select></td>
</tr>
<tr>
<td>Type of Inquiry:</td>
<td><select name="inquiryOptions" tabindex="6">
<option selected="selected">Technical Question</option>
<option>Product Question</option>
<option>Service Question</option>
<option>Other</option>
</select>&nbsp;</td>
</tr>
<tr>
<td>What's on your mind?</td>
<td><textarea cols="70" name="comment" rows="8" tabindex="7"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input name="submit" tabindex="8" type="submit" value="Submit" />&nbsp;
<input name="reset" tabindex="9" type="reset" value="Reset" /></td>
</tr>
</table>

</form>
</div>

Open in new window


Here is the email processor code:
<?php 

	$to = 'info@hcscomputersolutions.com';
	$subject = $_POST['inquiryOptions'];
	$header = $_POST['emailAddress'];
	$message = "From: $fullName\nBusiness Name: $businessName\nSender e-mail address: $header\nSender phone number: $phoneNumber\nPreferred method of contact: $contact\nRegarding: $subject\n\nMessage:\n$comment\n";

if ($header=="") {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}

$success = mail ($to, $subject, $message, "From: <$header>");

if ($success){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=success.html\">";
}
else {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=failure.html\">";
}

 ?>

Open in new window


Here is the email that we get sent, please know i entered information into every available field and the only one we received was the email and the drop down menu input.

From:
Business Name:
Sender e-mail address: test@test.com
Sender phone number:
Preferred method of contact:
Regarding: Technical Question

Message:

Please advise as to what I need to change now to get this fixed because I know absolutely nothing about PHP.

Thanks!
0
Comment
Question by:warsawtech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39842085
You processor code is missing this line:

Missed line:
$content = $_POST['content'];

Open in new window


Your code:
	$to = 'info@hcscomputersolutions.com';
	$subject = $_POST['inquiryOptions'];
	$header = $_POST['emailAddress'];
	$message = "From: $fullName\nBusiness Name: $businessName\nSender e-mail address: $header\nSender phone number: $phoneNumber\nPreferred method of contact: $contact\nRegarding: $subject\n\nMessage:\n$comment\n";

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39842106
I believe this article explains what happened.  You must modify this script.  You may need to modify other PHP scripts, too.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39842111
Marco: I think our author has bigger problems than that.  Follow the string fullName through both of the scripts.  It's an undefined variable in the PHP action= script.  If it used to work and now it does not work, that variable was getting injected into the symbol table and now it's not getting injected.

Executive summary: The hosting company did a PHP upgrade and Register Globals is gone (as it should be!) after the upgrade.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39842155
Oh, yes, you're right. I started to program with php eight years ago and I remember that Kevin Yank adivised against Register Globals yet. So I never had them active and I always forget them!
But it's interesting to see how fast is the knowledge progress and how slow is the human being to update itself to the latest news! And we're still dealing with Register Globals: when journalists
write about the fastness of information technology they don't imagine how slow it can be in some aspects :)

So could we say the same about $content?

Cheers
0
 
LVL 2

Author Comment

by:warsawtech
ID: 39842157
As I said in my post, I know nothing about PHP. I got the code from a different site and just modified it for my purposes.

Thanks for the link but It doesn't help with how I modify the code...it is literally all Greek to me. Thanks for the education but it's not dumbed down enough for me.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39842228
You may need professional help.  How many PHP scripts do you have in your site?

If you want to learn PHP this article can help you get started.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
0
 
LVL 2

Author Comment

by:warsawtech
ID: 39842264
Just one, Ray. The one I'm having problems with. Not really wanting to "learn" the programming language just to make my email form work.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39842325
You're in luck.  I can fix this for you.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39842346
BACK UP YOUR CURRENT EMAIL SCRIPT!!

Then install this in place of the email script and test it.  Please let me know how it works out.

<?php 

	$to = 'info@hcscomputersolutions.com';
	$subject = $_POST['inquiryOptions'];
	$header = $_POST['emailAddress'];
/**
 * REMEDIATED ON 2014-02-07 TO REMOVE
 * DEPENDENCY ON PHP REGISTER_GLOBALS
 */
$fullName     = $_POST['fullName'];
$businessName = $_POST['businessName'];
$phoneNumber  = $_POST['phoneNumber'];
$contact      = $_POST['contact'];
$comment      = $_POST['comment'];
/**
 * END OF REMEDIATION CODE
 */

	$message = "From: $fullName\nBusiness Name: $businessName\nSender e-mail address: $header\nSender phone number: $phoneNumber\nPreferred method of contact: $contact\nRegarding: $subject\n\nMessage:\n$comment\n";

if ($header=="") {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}

$success = mail ($to, $subject, $message, "From: <$header>");

if ($success){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=success.html\">";
}
else {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=failure.html\">";
}

 ?>

Open in new window

0
 
LVL 2

Author Comment

by:warsawtech
ID: 39842378
Ray, you're awesome! That worked perfectly. Thanks!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39842417
Great!  Thanks for using EE and thanks for the points.

I'm going to update that article to add the remediation methodology.  Since Register_Globals is gone in PHP 5.4 and PHP 5.3 is in end-of-life today, I expect others will encounter the same thing you did.

Best regards, ~Ray
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question