i got this emailing php form online. its open source. im not too great with php and i tried editing the form to add a “Type of Business” and “Revenue size of Business” Field in the sent email but its not working. Here’e the unedited code:
<?php
// Copyright (C) 2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
// Instead, you may link to the homepage of this code:
// http://www.php-development.ru/php-scripts/contact-form.php
// (3) Use this code as part of another product.
//
// YOU MAY
// (1) Use this code on your website.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.
?>
<!-- ***** Configuration *************************************************** -->
<?php
$contact_form_field_name = 'Name:';
$contact_form_field_email = 'E-mail:';
$contact_form_field_subject = 'Subject:';
$contact_form_field_message = 'Message:';
$contact_form_field_number = 'Turing number:';
$contact_form_field_prompt = 'Enter the number displayed above';
$contact_form_button = 'Submit';
$contact_form_sent = 'Message sent';
$contact_form_not_sent = 'Message not sent';
$contact_form_invalid_data = 'Please, correct the fields marked with red';
?>
<div class="contact_form">
<!-- ***** PHP ************************************************************* -->
<?php
// ***** Functions *****
function contact_form_post($name)
{
return isset($_POST[$name]) ? htmlentities($_POST[$name], ENT_COMPAT) : '';
}
// ***** Send Mail *****
if (isset($_POST['Contact']))
{
if (get_magic_quotes_gpc() && !function_exists('strip_slashes_deep'))
{
function strip_slashes_deep($value)
{
if (is_array($value)) return array_map('strip_slashes_deep', $value);
return stripslashes($value);
}
$_GET = strip_slashes_deep($_GET);
$_POST = strip_slashes_deep($_POST);
$_COOKIE = strip_slashes_deep($_COOKIE);
}
$patern_aux1 = "(\\w+(-\\w+)*)";
$patern_aux2 = "($patern_aux1\\.)*$patern_aux1@($patern_aux1\\.)+$patern_aux1";
$valid_name = isset($_POST['Name' ]) && trim($_POST['Name' ]);
$valid_email = isset($_POST['Email' ]) && preg_match("/^$patern_aux2$/iX", $_POST['Email']);
$valid_subject = isset($_POST['Subject']) && trim($_POST['Subject']);
$valid_message = isset($_POST['Message']) && trim($_POST['Message']);
$valid_number = isset($_POST['Number' ]) && isset($_SESSION['Number']) && $_POST['Number'] == $_SESSION['Number'];
if (!$valid_name) $contact_form_field_name = "<em>$contact_form_field_name </em>";
if (!$valid_email) $contact_form_field_email = "<em>$contact_form_field_email </em>";
if (!$valid_subject) $contact_form_field_subject = "<em>$contact_form_field_subject</em>";
if (!$valid_message) $contact_form_field_message = "<em>$contact_form_field_message</em>";
if (!$valid_number) $contact_form_field_number = "<em>$contact_form_field_number </em>";
if ($valid_name && $valid_email && $valid_subject && $valid_message && $valid_number)
{
$error_reporting = error_reporting(E_ERROR | E_PARSE);
$mail_sent = mail($contact_form_your_email,
$_POST['Subject'],
$contact_form_message_prefix . $_POST['Message'],
"To: $contact_form_your_name <$contact_form_your_email>
" .
"From: {$_POST['Name']} <{$_POST['Email']}>
");
error_reporting($error_reporting);
if ($mail_sent)
echo "<div class=\"error\"><em> $contact_form_sent </em></div>";
else echo "<div class=\"error\"><em class=\"error\">$contact_form_not_sent</em></div>";
if ($mail_sent) $_POST = array();
}
else echo "<div class=\"contact_form\"><div class=\"error\"><em>$contact_form_invalid_data</em></div></div>";
}
$_SESSION['Number'] = str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT);
?>
<!-- ***** IE Patch ******************************************************** -->
<!--[if IE]><style type="text/css"> div.contact_form div.input input { margin-top: -1px; margin-bottom: -1px; } </style><![endif]-->
<!--[if IE]><style type="text/css"> div.contact_form div.input textarea { margin-top: -1px; margin-bottom: -1px; } </style><![endif]-->
<!-- ***** XHTML *********************************************************** -->
<?php if ( $contact_form_xhtml) { ?>
<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table>
<tr><th><?=$contact_form_field_name; ?></th><td><div class="input"><input name= "Name" type="text" value="<?=contact_form_post( 'Name');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_email; ?></th><td><div class="input"><input name= "Email" type="text" value="<?=contact_form_post( 'Email');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_subject;?></th><td><div class="input"><input name="Subject" type="text" value="<?=contact_form_post('Subject');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_message;?></th><td><div class="input"><textarea name="Message" cols="35" rows="6"><?=contact_form_post('Message');?></textarea></div></td></tr>
<tr><th><?=$contact_form_field_number;?></th><td>
<div class="input" style="float: left;"><input type="text" name="Number" autocomplete="off" /></div>
<img width="60" height="17" src="<?=$contact_form_image_url;?>?sname=<?=session_name();?>&rand=<?=rand();?>" alt="" />
<br style="clear: both" />
<small><?=$contact_form_field_prompt;?></small>
</td></tr>
<tr><th></th><td><input id="submit_contact" class="submit" type="submit" name="Contact" value="<?=$contact_form_graphic_button ? '' : $contact_form_button;?>" /></td></tr>
</table>
</form>
<?php } ?>
<!-- ***** HTML ************************************************************ -->
<?php if (!$contact_form_xhtml) { ?>
<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table>
<tr><th><?=$contact_form_field_name; ?></th><td><div class="input"><input name= "Name" type="text" value="<?=contact_form_post( 'Name');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_email; ?></th><td><div class="input"><input name= "Email" type="text" value="<?=contact_form_post( 'Email');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_subject;?></th><td><div class="input"><input name="Subject" type="text" value="<?=contact_form_post('Subject');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_message;?></th><td><div class="input"><textarea name="Message" cols="35" rows="6"><?=contact_form_post('Message');?></textarea></div></td></tr>
<tr><th><?=$contact_form_field_number;?></th><td>
<div class="input" style="float: left;"><input type="text" name="Number" autocomplete="off"></div>
<img width="60" height="17" src="<?=$contact_form_image_url;?>?sname=<?=session_name();?>" alt="">
<br style="clear: both">
<small><?=$contact_form_field_prompt;?></small>
</td></tr>
<tr><th></th><td><input id="submit_contact" class="submit" type="submit" name="Contact" value="<?=$contact_form_graphic_button ? '' : $contact_form_button;?>"></td></tr>
</table>
</form>
<?php } ?>
</div>
and here’s how I tried to edit it
<?php
// Copyright (C) 2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
// Instead, you may link to the homepage of this code:
// http://www.php-development.ru/php-scripts/contact-form.php
// (3) Use this code as part of another product.
//
// YOU MAY
// (1) Use this code on your website.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.
?>
<!-- ***** Configuration *************************************************** -->
<?php
$contact_form_field_name = 'Name:';
$contact_form_field_email = 'E-mail:';
$contact_form_field_subject = 'Subject:';
$contact_form_field_type = 'Type:';
$contact_form_field_revenue = 'Revenue:';
$contact_form_field_message = 'Goal:';
$contact_form_field_number = 'Turing number:';
$contact_form_field_prompt = 'Enter the number displayed above';
$contact_form_button = 'Submit';
$contact_form_sent = 'Message sent';
$contact_form_not_sent = 'Message not sent';
$contact_form_invalid_data = 'Please, correct the fields marked with red';
?>
<div class="contact_form">
<!-- ***** PHP ************************************************************* -->
<?php
// ***** Functions *****
function contact_form_post($name)
{
return isset($_POST[$name]) ? htmlentities($_POST[$name], ENT_COMPAT) : '';
}
// ***** Send Mail *****
if (isset($_POST['Contact']))
{
if (get_magic_quotes_gpc() && !function_exists('strip_slashes_deep'))
{
function strip_slashes_deep($value)
{
if (is_array($value)) return array_map('strip_slashes_deep', $value);
return stripslashes($value);
}
$_GET = strip_slashes_deep($_GET);
$_POST = strip_slashes_deep($_POST);
$_COOKIE = strip_slashes_deep($_COOKIE);
}
$patern_aux1 = "(\\w+(-\\w+)*)";
$patern_aux2 = "($patern_aux1\\.)*$patern_aux1@($patern_aux1\\.)+$patern_aux1";
$valid_name = isset($_POST['Name' ]) && trim($_POST['Name' ]);
$valid_email = isset($_POST['Email' ]) && preg_match("/^$patern_aux2$/iX", $_POST['Email']);
$valid_subject = isset($_POST['Subject']) && trim($_POST['Subject']);
$valid_type = isset($_POST['Type']) && trim($_POST['Type' ]);
$valid_revenue = isset($_POST['Revenue']) && trim($_POST['Revenue' ]);
$valid_message = isset($_POST['Message']) && trim($_POST['Message']);
$valid_number = isset($_POST['Number' ]) && isset($_SESSION['Number']) && $_POST['Number'] == $_SESSION['Number'];
if (!$valid_name) $contact_form_field_name = "<em>$contact_form_field_name </em>";
if (!$valid_email) $contact_form_field_email = "<em>$contact_form_field_email </em>";
if (!$valid_subject) $contact_form_field_subject = "<em>$contact_form_field_subject</em>";
if (!$valid_type) $contact_form_field_type = "<em>$contact_form_field_type </em>";
if (!$valid_revenue) $contact_form_field_revenue = "<em>$contact_form_field_revenue</em>";
if (!$valid_message) $contact_form_field_message = "<em>$contact_form_field_message</em>";
if (!$valid_number) $contact_form_field_number = "<em>$contact_form_field_number </em>";
if ($valid_name && $valid_email && $valid_subject && $valid_message && $valid_number)
{
$error_reporting = error_reporting(E_ERROR | E_PARSE);
$mail_sent = mail($contact_form_your_email,
$_POST['Subject'],
$contact_form_message_prefix . $_POST['Type'] , $_POST['Revenue'] $_POST['Message'],
"To: $contact_form_your_name <$contact_form_your_email>
" .
"From: {$_POST['Name']} <{$_POST['Email']}>
");
error_reporting($error_reporting);
if ($mail_sent)
echo "<div class=\"error\"><em> $contact_form_sent </em></div>";
else echo "<div class=\"error\"><em class=\"error\">$contact_form_not_sent</em></div>";
if ($mail_sent) $_POST = array();
}
else echo "<div class=\"contact_form\"><div class=\"error\"><em>$contact_form_invalid_data</em></div></div>";
}
$_SESSION['Number'] = str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT);
?>
<!-- ***** IE Patch ******************************************************** -->
<!--[if IE]><style type="text/css"> div.contact_form div.input input { margin-top: -1px; margin-bottom: -1px; } </style><![endif]-->
<!--[if IE]><style type="text/css"> div.contact_form div.input textarea { margin-top: -1px; margin-bottom: -1px; } </style><![endif]-->
<!-- ***** XHTML *********************************************************** -->
<?php if ( $contact_form_xhtml) { ?>
<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table>
<tr><th><?=$contact_form_field_name; ?></th><td><div class="input"><input name= "Name" type="text" value="<?=contact_form_post( 'Name');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_email; ?></th><td><div class="input"><input name= "Email" type="text" value="<?=contact_form_post( 'Email');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_subject;?></th><td><div class="input"><input name="Subject" type="text" value="<?=contact_form_post('Subject');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_type;?></th><td><div class="input"><input name="Type of Business" type="text" value="<?=contact_form_post('Type of Business');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_revenue;?></th><td><div class="input"><input name="Revenue Size of Business" type="text" value="<?=contact_form_post('Revenue Size of Business');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_message;?></th><td><div class="input"><textarea name="Message" cols="35" rows="6"><?=contact_form_post('Message');?></textarea></div></td></tr>
<tr><th><?=$contact_form_field_number;?></th><td>
<div class="input" style="float: left;"><input type="text" name="Number" autocomplete="off" /></div>
<img width="60" height="17" src="<?=$contact_form_image_url;?>?sname=<?=session_name();?>&rand=<?=rand();?>" alt="" />
<br style="clear: both" />
<small><?=$contact_form_field_prompt;?></small>
</td></tr>
<tr><th></th><td><input id="submit_contact" class="submit" type="submit" name="Contact" value="<?=$contact_form_graphic_button ? '' : $contact_form_button;?>" /></td></tr>
</table>
</form>
<?php } ?>
<!-- ***** HTML ************************************************************ -->
<?php if (!$contact_form_xhtml) { ?>
<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table>
<tr><th><?=$contact_form_field_name; ?></th><td><div class="input"><input name= "Name" type="text" value="<?=contact_form_post( 'Name');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_email; ?></th><td><div class="input"><input name= "Email" type="text" value="<?=contact_form_post( 'Email');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_subject;?></th><td><div class="input"><input name="Subject" type="text" value="<?=contact_form_post('Subject');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_type;?></th><td><div class="input"><input name="Type of Business" type="text" value="<?=contact_form_post('Type of Business');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_revenue;?></th><td><div class="input"><input name="Revenue Size of Business" type="text" value="<?=contact_form_post('Revenue Size of Business');?>" ></div></td></tr>
<tr><th><?=$contact_form_field_message;?></th><td><div class="input"><textarea name="Message" cols="35" rows="6"><?=contact_form_post('Message');?></textarea></div></td></tr>
<tr><th><?=$contact_form_field_number;?></th><td>
<div class="input" style="float: left;"><input type="text" name="Number" autocomplete="off"></div>
<img width="60" height="17" src="<?=$contact_form_image_url;?>?sname=<?=session_name();?>" alt="">
<br style="clear: both">
<small><?=$contact_form_field_prompt;?></small>
</td></tr>
<tr><th></th><td><input id="submit_contact" class="submit" type="submit" name="Contact" value="<?=$contact_form_graphic_button ? '' : $contact_form_button;?>"></td></tr>
</table>
</form>
<?php } ?>
</div>
any help?