Jump to content

[SOLVED] undefined index in mail form


aebstract

Recommended Posts

[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  name2 in /home/virtual/site21/fst/var/www/html/contform.php on line 253
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  company in /home/virtual/site21/fst/var/www/html/contform.php on line 258
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  email in /home/virtual/site21/fst/var/www/html/contform.php on line 263
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  phone1 in /home/virtual/site21/fst/var/www/html/contform.php on line 268
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  phone2 in /home/virtual/site21/fst/var/www/html/contform.php on line 269
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  phone3 in /home/virtual/site21/fst/var/www/html/contform.php on line 270
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  address2 in /home/virtual/site21/fst/var/www/html/contform.php on line 275
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  city in /home/virtual/site21/fst/var/www/html/contform.php on line 280
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  state in /home/virtual/site21/fst/var/www/html/contform.php on line 281
[Wed Dec 17 16:30:00 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined index:  zip in /home/virtual/site21/fst/var/www/html/contform.php on line 286
[Wed Dec 17 16:30:03 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined variable: problem in /home/virtual/site21/fst/var/www/html/contform.php on line 52, referer: http://berryequipment.net/contform.php
[Wed Dec 17 16:30:03 2008] [error] [client 70.155.67.57] PHP Notice:  Undefined variable: type in /home/virtual/site21/fst/var/www/html/contform.php on line 78, referer: http://berryequipment.net/contform.php

 

this is from the error reports i have.

 

<?php
if (isset ($_POST['submit'])) {

if (empty ($_POST['name2'])) {
$problem = TRUE;
echo "PROBLEM NAME";
}
if (empty ($_POST['company'])) {
$problem = TRUE;
echo "PROBLEM COMPANY";
}
if (empty ($_POST['email'])) {
$problem = TRUE;
echo "PROBLEM EMAIL";
}
if (empty ($_POST['phone1'])) {
$problem = TRUE;
echo "PROBLEM P1";
}
if (empty ($_POST['phone2'])) {
$problem = TRUE;
echo "PROBLEM P2";
}
if (empty ($_POST['phone3'])) {
$problem = TRUE;
echo "PROBLEM P3";
}
if (empty ($_POST['address2'])) {
$problem = TRUE;
echo "PROBLEM ADDRESS";
}
if (empty ($_POST['city'])) {
$problem = TRUE;
echo "PROBLEM CITY";
}
if (empty ($_POST['state'])) {
$problem = TRUE;
echo "PROBLEM STATE";
}
if (empty ($_POST['zip'])) {
$problem = TRUE;
echo "PROBLEM ZIP";
}
if (empty ($_POST['level'])) {
$problem = TRUE;
echo "PROBLEM LEVEL";
}




if (!$problem) {
$name2 = $_POST['name2'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$phone3 = $_POST['phone3'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];


$emailbody = "

		$name2<br />
		$company<br />
		$email<br />
		$phone1 - $phone2 - $phone3<br />
		$address2<br />
		$city, $state $zip

		<br /><br />

		Type: $type

		";


		$to  = 'aebstract@gmail.com' . ', '; // note the comma

		// subject
		$subject = 'Contingency Form';

		// message
		$message = "
		<html>
		<head>
		</head>
		<body>
		$emailbody
		</body>
		</html>
		";

		// To send HTML mail, the Content-type header must be set
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		// Additional headers
		$headers .= 'To: Todd Berry <aebstract@gmail.com>' . "\r\n";

		// Mail it
		mail($to, $subject, $message, $headers);


                      header("Location: contform2.php");




} else {
echo "PROBLEM";
}
}

?>
<html>
<head>
<style type="text/css">
body {
text-align: center;
background-color: #000000;
margin: 0px;
spacing: 0px;
}

ul {
font-family: arial;
font-size: 15px;
margin-left: 50px;
margin-right: 20px;
}
li {
padding: 5px;
}
h1 {
color: #ff0000;
font-family: arial;
font-size: 25px;
margin-left: 55px;
}
h2 {
color: #000000;
font-family: arial;
font-size: 20px;
text-align: right;
}
</style>
</head>
<body>
<div style="background-color: #FFFFFF; width: 950px; text-align: left; margin-left: auto; margin-right: auto;">

<img src="orsca.jpg" style="float: right;" /><img src="spacer.gif" height="150" />

<h1>ORSCA CONTINGENCY PROGRAM</h1>

<p style="padding-left:25px; padding-right:25px; font-size: 17px; font-family: arial;">A contingency sponsorship program is an advertisement program like no other. A sponsorship program where the racer purchases your product or service before
they are elegible for your sponsorship dollars. On top of that, the racer advertises your company or brand on their vehicle throughout the event and you only
pay them if they are a winner or runner-up. Contingency sponsorship is an incentive program of sorts. One where you're not only exposing thousands of potential
customers to your company or brand but you're ensuring that racers have an even greater reason to purchase your products or services.</p>

<p style="padding-left:25px; padding-right:25px; font-size: 17px; font-family: arial;">Let us face it, you will not find a racer that thinks they are going to lose on any given weekend. Each and every racer believes that he or she can win and they are right.
On any given weekend anyone can win a drag race. With the right performance parts and tuning a racer can set themselves up to have that little edge. Remember, what is fast on
Sunday sells on Monday.</p>

<p style="padding-left:25px; padding-right:25px; font-size: 17px; font-family: arial;">So how does this contingency program work? There is a list of criteria a racer must meet in order to receive any monetary compensation.</p>

<ul>
<li>Competitors must first purchase the nominated product or service and be actively using the product or service before they are eligible for your contingency rewards.</li>
<li>Your company or product decal must be displayed in an easy to view position on the race car.</li>
<li>Sponsors may include special requirekents such as proof of purchase, serial numbers, etc.</li>
<li>Any competitor found falsly claiming product use or applying decals after start of the event will forfeit all contingency rewards for said event.</li>
<li>Competitors must be a member of the Outlaw Racing Street Car Association to be eligible for prizes.</li>
<li>Contigency rewards are limited only to finishers designated by sponsor. (EX: winner and runner-up)</li>
<li>ORSCA will inspect all contingency winning cars for proper sticker placement, part receipt, etc.</li>
</ul>


<br /><br /><br />
<h1>SPONSOR WILL RECEIVE THE FOLLOWING</h1>

<ul>
<li>Company or product banner along race wall.</li>
<li>PA Announcements promoting your company and/or products.</li>
<li>All promos will have sponsoring company's logo (ex: t-shirts, flyers, etc.)</li>
<li>ORSCA will post all results for contingency payouts along with sponsor mention.</li>
<li>All sponsored cars will run your logo.</li>
<li>ORSCA will examine all cars making sure all criteria is met for competitor eligibility</li>
</ul>

<br /><br />

<h1>SIGN UP</h1>

<form action="contform.php" method="post" name"contact">


<table cellspacing="0" cellpadding="10" style="color:#000000; font-family: arial; font-size: 13px;" align="center">
<tr><td valign="top">

<br />
<h2>Contingency Levels  </h2>
<?php
echo "


<p>
<table cellspacing=\"0\" cellpadding=\"5\" style=\"color:#999999; font-family: arial; font-size: 13px;\" align=\"right\">
<tr style=\"color:#000000; font-family: arial; font-size: 13px;\"><td>
Level
</td><td width=10></td><td>
Winner
</td><td width=10></td><td>
Runner Up
</td></tr>
<tr bgcolor=\"#000000\"><td>
<input type=\"radio\" name=\"level\" value=\"a\" checked />A
</td><td width=10></td><td>
300
</td><td width=10></td><td>
150
</td></tr>
<tr bgcolor=\"#333333\"><td>
<input type=\"radio\" name=\"level\" value=\"b\" />B
</td><td width=10></td><td>
200
</td><td width=10></td><td>
100
</td></tr><tr bgcolor=\"#000000\"><td>
<input type=\"radio\" name=\"level\" value=\"c\" />C
</td><td width=10></td><td>
100
</td><td width=10></td><td>
50
</td></tr>
</table>
</p>
<p style=\"color:#000000; font-family: arial; font-size: 15px;\"><br /><br />There will be a one-time administrative setup fee of $1800.</p>

";

?>
</td><td valign="top">

<?php
echo "
<table cellspacing=\"0\" cellpadding=\"10\" style=\"color:#999999; font-family: arial; font-size: 13px;\">
<tr bgcolor=\"#000\"><td align=\"right\">
Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"name2\" value=\"$_POST[name2]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Company Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"company\" value=\"$_POST[company]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Email
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"email\" value=\"$_POST[email]\" size=\"30\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Phone Number
</td><td>
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone1\" value=\"$_POST[phone1]\" size=\"3\" />
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone2\" value=\"$_POST[phone2]\" size=\"3\" />
<input type=\"text\" maxlength=\"4\" class=\"textfield2\" name=\"phone3\" value=\"$_POST[phone3]\" size=\"4\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Address
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"address2\" value=\"$_POST[address2]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
City, State
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"city\" value=\"$_POST[city]\" size=\"13\" />
<input type=\"text\" maxlength=\"2\" class=\"textfield2\" name=\"state\" value=\"$_POST[state]\" size=\"2\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Zip
</td><td align=\"right\">
<input type=\"text\" maxlength=\"5\" class=\"textfield2\" name=\"zip\" value=\"$_POST[zip]\" size=\"5\" />
</td></tr>
<tr><td align=\"right\">
</td><td align=\"right\">
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</td></tr>

</table>
";
?>
</td>
</tr>
</table>





</form>

</div>
</body>
</html>

Link to comment
Share on other sites

at the bottom of that script...you use $_POST[index] (where index is several different values) in your form. those keys in the array don't exist. 'proper' coding says you should check for the value before you try to echo it. but, i find it silly. just adjust your error reporting to not include NOTICE (this is actually PHP's default).

 

in your php.ini, find the 'error_reporting' setting and set it to:

error_reporting  =  E_ALL & ~E_NOTICE

Link to comment
Share on other sites

not sure if this is necessary but shouldn't you change

 

<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"name2\" value=\"$_POST[name2]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Company Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"company\" value=\"$_POST[company]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Email
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"email\" value=\"$_POST[email]\" size=\"30\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Phone Number
</td><td>
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone1\" value=\"$_POST[phone1]\" size=\"3\" />
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone2\" value=\"$_POST[phone2]\" size=\"3\" />
<input type=\"text\" maxlength=\"4\" class=\"textfield2\" name=\"phone3\" value=\"$_POST[phone3]\" size=\"4\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Address
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"address2\" value=\"$_POST[address2]\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
City, State
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"city\" value=\"$_POST[city]\" size=\"13\" />
<input type=\"text\" maxlength=\"2\" class=\"textfield2\" name=\"state\" value=\"$_POST[state]\" size=\"2\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Zip
</td><td align=\"right\">
<input type=\"text\" maxlength=\"5\" class=\"textfield2\" name=\"zip\" value=\"$_POST[zip]\" size=\"5\" />

 

to..

 

<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"name2\" value=\"".$_POST['name2']."\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Company Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"company\" value=\"".$_POST['company']."\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Email
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"email\" value=\"".$_POST['email']."\" size=\"30\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
Phone Number
</td><td>
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone1\" value=\"".$_POST['phone1']."\" size=\"3\" />
<input type=\"text\" maxlength=\"3\" class=\"textfield2\" name=\"phone2\" value=\"".$_POST['phone2']."\" size=\"3\" />
<input type=\"text\" maxlength=\"4\" class=\"textfield2\" name=\"phone3\" value=\"".$_POST['phone3']."\" size=\"4\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Address
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"address2\" value=\"".$_POST['address2']."\" size=\"20\" />
</td></tr>
<tr bgcolor=\"#000\"><td align=\"right\">
City, State
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"city\" value=\"".$_POST['city']."\" size=\"13\" />
<input type=\"text\" maxlength=\"2\" class=\"textfield2\" name=\"state\" value=\"".$_POST['state']."\" size=\"2\" />
</td></tr>
<tr bgcolor=\"#333333\"><td align=\"right\">
Zip
</td><td align=\"right\">
<input type=\"text\" maxlength=\"5\" class=\"textfield2\" name=\"zip\" value=\"".$_POST['zip']."\" size=\"5\" />  

 

im still a php noob.. but this is what i think is wrong

Link to comment
Share on other sites

find it silly. just adjust your error reporting to not include NOTICE (this is actually PHP's default).

 

You might find it silly, but its actually just as easy to fix the problem and let your php be parsed as efficiently and correctly  as possible.

 

All you would need to do for instance is change a line like this....

 

<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"email\" value=\"".$_POST['email']."\" size=\"30\" />

 

to....

 

<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"email\" value=\"" . isset($_POST['email']) ? $_POST['email'] : '' . "\" size=\"30\" />

Link to comment
Share on other sites

It's a hosted service, and I've had customers going to the website for a long time now and using the contact form, which we receive email from. (Just tested it and it went through almost immediately)

 

If it works, than what is the issue?

Link to comment
Share on other sites

I don't really see a difference and I mainly copied the main part of the mail function from it so I don't see why it doesn't work. I can try redoing the thing to make sure but I don't know :/

 

edit:

heres my contact form on the main website:

<?php



if (isset ($_POST['submit'])) {

if (empty ($_POST['firstname'])) {
$problem = TRUE;
$error .= 'Your firstname is a required field!<br />';
}







	if (!$problem) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$name = "$firstname $lastname";
$phonenumber1 = $_POST['phonenumber1'];
$phonenumber2 = $_POST['phonenumber2'];
$phonenumber3 = $_POST['phonenumber3'];
$msg = $_POST['msg'];



	$emailbody = "

	$name<br />
	$email<br />
	$phonenumber1-$phonenumber2-$phonenumber3<br /><br />

	$msg

	";


	$to  = 'webadmin@berryequipment.net' . ', '; // note the comma

	// subject
	$subject = 'Contact Form';

	// message
	$message = "
	<html>
	<head>
	</head>
	<body>
	$emailbody
	</body>
	</html>
	";

	// To send HTML mail, the Content-type header must be set
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	// Additional headers
	$headers .= 'To: Berry Plumbing & Equipment <webadmin@berryequipment.net>' . "\r\n";

	// Mail it
	mail($to, $subject, $message, $headers);


                      header("Location: /contact/true/");



	}

}

if ($va1 == true){

$content .= "Thank you for submitting your message, we will get in touch with you as soon as possible.";

} else {

$content .= "

<form action=\"/contact/\" method=\"post\" name=\"contact\">

<h4>Contact Form</h4>
<center>
<div id=\"form\">
<table><tr><td>
<table class=\"formstyle\">
<tr class=\"tabletr\"><td align=\"right\">
First Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"firstname\" value=\"$_POST[firstname]\" size=\"20\" />
</td></tr>
<tr><td align=\"right\">
Last Name
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield2\" name=\"lastname\" value=\"$_POST[lastname]\" size=\"20\" />
</td></tr>
<tr><td align=\"right\">
Email Address
</td><td>
<input type=\"text\" maxlength=\"50\" class=\"textfield2\" name=\"email\" value=\"$_POST[email]\" size=\"20\" />
</td></tr>
<tr><td align=\"right\">
Telephone
</td><td>
<input type=\"text\" size=\"3\" class=\"textfield2\" onKeyup=\"autotab(this, document.contact.phonenumber2)\" maxlength=\"3\" name=\"phonenumber1\" value=\"$_POST[phonenumber1]\" />
<input type=\"text\" size=\"3\" class=\"textfield2\"  onKeyup=\"autotab(this, document.contact.phonenumber3)\" maxlength=\"3\" name=\"phonenumber2\" value=\"$_POST[phonenumber2]\" />
<input type=\"text\" size=\"3\" class=\"textfield2\" maxlength=\"4\" name=\"phonenumber3\" value=\"$_POST[phonenumber3]\" />
</td></tr>
</table></td><td>
Message:
<textarea cols=\"30\" rows=\"3\" name=\"msg\" class=\"textfield2\" value=\"$_POST[msg]\"></textarea><br />
   <input type=\"submit\" name=\"submit\" class=\"textfield2\" value=\"Send\" />
</td></tr></table>
</div>
</center>

</form>

<br /><br /><br />

6736 Cleveland Hwy,<br />
Clermont, GA 30527<br />
<br />
Phone: 770-983-3929<br />
Fax: 866-808-9957
";
}
?>

Link to comment
Share on other sites

The main difference I see is the email.

 

Are you sure your GMail account is not setup to trash/send the message to spam? Add the from domain to your safelist. I would also try it with a different email and see.

 

Just to make sure, you are running this script on the same server, right? And not your local one...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.