Reply to Re: Undefine index error

Your name:

Reply:


Posted by shimmyshack on 09/04/07 22:42

On Sep 4, 10:49 pm, JJM0926 <jjm0...@gmail.com> wrote:
> I've got a contact form with a submit button where users have to enter
> their support information. Some fields are required some are not.
> When I test out the form if I leave everything blank I get these two
> undefined index error :
>
> Notice: Undefined index: CurrentCustomer in E:\WebSites\mysite\www
> \contactus.php on line 9
>
> Notice: Undefined index: ContactMethod in E:\WebSites\mysite\www
> \contactus.php on line 19
>
> If I fill out at least the required fields everything is fine.
>
> Here's what the code looks like:
>
> <?php
> if (isset($_POST["Submit"])) // Trigger
> {
> // Email Request
> $to = "supp...@myisp.com";
> $subject = "Here Is My Contact Information";
> $email = $_POST['Email'];
> $message = "";
> if isset($_POST['CurrentCustomer']) {
> $message = $message."Current Customer: ".
> $_POST['CurrentCustomer']."\n";
> }
> if isset($_POST['Name']) {
> $message = $message."Name: ".$_POST['Name']."\n";
> }
> if isset($_POST['CoName']) {
> $message = $message."Company Name: ".$_POST['CoName']."\n";
> }
> if isset($_POST['Phone']) {
> $message = $message."Phone Number: ".$_POST['Phone']."\n";
> }
> if isset($_POST['Fax']) {
> $message = $message."Fax Number: ".$_POST['Fax']."\n";
> }
> if isset($_POST['Email']) {
> $message = $message."E-Mail Address: ".$_POST['Email']."\n";
> }
> if isset($_POST['Manufacturer']) {
> $message = $message."Manufacturer: ".$_POST['Manufacturer']."\n";
> }
> if isset($_POST['Model']) {
> $message = $message."Model Number: ".$_POST['Model']."\n";
> }
> if isset($_POST['Serial']) {
> $message = $message."Serial Number: ".$_POST['Serial']."\n";
> }
> if isset($_POST['Message']) {
> $message = $message."Message: ".$_POST['Message']."\n";
> }
> if isset($_POST['ContactMethod']) {
> $message = $message."Preferred Contact Method: ".
> $_POST['ContactMethod']."\n";
> }
> mail( $to, $subject, $message, "From: $email" );
> }
> ?>


i advise you to download a secure form that attempts to do some
checking before emailing.
as for the notices, use error_reporting(0) to turn off anything you
dont want, and google for programming standards, there are many
problems with the code as is, formatting, as well as $message =
$message .'blah' etc... I suggest a good read through the manual
before you expose your server and the world to spam and lots of it.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация