Solved

PHP Email Form Issues

Posted on 2014-02-07
11
538 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
  • 6
  • 3
  • 2
11 Comments
 
LVL 30

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 108

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 108

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
 
LVL 30

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 108

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 108

Expert Comment

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

Accepted Solution

by:
Ray Paseur earned 500 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 108

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scandir() not reads all files 4 27
session dropped in IE 10 22
mysql left join sentence 7 22
regex expression 9 23
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now