I’ve been trying to add some sort of warning/alert for my form to email page (aka contact us page) and failed ? so now asking for help.
My form has got an alert for an incorrect email format, but I need some extra alerts for name, postcode and phone entry boxes.
Can anyone help me please or point me in the right direction? Can I point out I’m no coder ? , hence asking for help.
My exsisting form has several features I’ve added and managed to get them working, like forwarding of the IP address, pre-defined text labels in the email body.
I’ve stripped my code down as much as possible in this request for help, as the ‘working’ copy has several additional text entry boxes and lots of formatting.
Thanks in advance for looking and any help ?
[code]<?php
require(‘includes/application_top.php’);
$error = false;
if (isset($HTTP_GET_VARS[‘action’]) && ($HTTP_GET_VARS[‘action’] == ‘send’)) {
$email_address = tep_db_prepare_input($HTTP_POST_VARS[’email’]);
//IP recorder start
$ipaddress = $HTTP_SERVER_VARS[“REMOTE_ADDR”];
$ip = “nn IP: ” . $ipaddress;
$content = $HTTP_POST_VARS[‘enquiry’];
$content_ip = $content . $ip;
$enquiry = tep_db_prepare_input($content_ip);
//IP recorder end
if (tep_validate_email($email_address)) {
tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT,
// start of pre-entered email text
“Full Name: ” . $name . “n”
. “E-mail: ” . $email . “n”
. “Phone Numer: ” . $phone . “n”
. “Postcode: ” . $postcode . “nn”
. “Message:<BR> ” . $enquiry . “n”
, $name, $email_address);
// end of pre-entered email text
tep_redirect(tep_href_link(FILENAME_CONTACT_US, ‘action=success’));
} else {
$error = true;
$messageStack->add(‘contact’, ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
}
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));
?>
<!doctype html public “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html <?php echo HTML_PARAMS; ?>>
<head>
<base href=”<?php echo (($request_type == ‘SSL’) ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>”>
</head>
<body>
<table><tr><td>
<?php echo tep_draw_form(‘contact_us’, tep_href_link(FILENAME_CONTACT_US, ‘action=send’)); ?>
<table>
<?php
if ($messageStack->size(‘contact’) > 0) {
?>
<tr> <td>
<!– email errormessage –><?php echo $messageStack->output(‘contact’); ?></td>
</tr>
<?php
}
if (isset($HTTP_GET_VARS[‘action’]) && ($HTTP_GET_VARS[‘action’] == ‘success’)) {
?>
<tr> <td>
<?php echo tep_image(DIR_WS_IMAGES . ‘table_background_man_on_board.gif’, HEADING_TITLE, ‘0’, ‘0’, ‘align=”left”‘) . TEXT_SUCCESS; ?></td>
</tr>
<tr> <td width=”10″></td>
<td align=”right”>
<?php echo ‘<a href=”‘ . tep_href_link(FILENAME_DEFAULT) . ‘”>’ . tep_image_button(‘button_continue.gif’, IMAGE_BUTTON_CONTINUE) . ‘</a>’; ?></td>
<td width=”10″></td>
</tr>
</table>
</td> </tr> </table>
<?php
} else {
?>
<table> <tr> <td>
<table>
<tr>
<td width=”100%” align=”center” colspan=”2″>
<?php echo TEXT_MAIN_TEXT; ?>
</td></tr>
<td>NAME;</td>
<td width=”50%”><?php echo tep_draw_input_field(‘name’); ?></td>
</tr>
<tr>
<td>ENTRY_EMAIL;</td>
<td width=”50%”><?php echo tep_draw_input_field(’email’); ?></td>
</tr>
<tr>
<td>POSTCODE</td>
<td width=”50%”><?php echo tep_draw_input_field(‘postcode’); ?></td>
</tr>
<tr>
<td>COUNTRY;</td>
<td width=”50%”><?php echo tep_draw_input_field(‘Country’); ?></td>
</tr>
<tr>
<td>PHONE;</td>
<td width=”50%”><?php echo tep_draw_input_field(‘phone’); ?></td>
</tr>
</table>
</td> </tr>
<tr> <td>Please Enter Your Message:</td> </tr>
<tr> <td><?php echo tep_draw_textarea_field(‘enquiry’, ‘soft’, 50, 5); ?></td>
</tr>
<tr> <td><?php echo tep_image_submit(‘submit-enquiry01.gif’, IMAGE_BUTTON_CONTINUE); ?></td>
</tr>
<?php
}
?>
</table></form>
</body></html><?php require(DIR_WS_INCLUDES . ‘application_bottom.php’); ?>