Hi all,

I couldn't add tags to this; error said I wasn't allowed to.

Win 7 Home Premium, Apache 1.7.3, PHP 5.3.3 (same as my remote server).

I started out with a working form I got from somewhere, forget where now. It worked well and it's 100% working remotely and locally.
However i ran into trouble when I tried to modify it to add a little security to the form. It used something called "check_input" I eventually figured out wasn't part of PHP and lots of problems ensued. It doesn't take kindly to maki ng some changes in the script.

So, I started from scratch just to make sure I understood everything that was going on. I have paired them down to the simplest scripts I can so I could fight errors as they occurred, all based on known-working prototype scripts.
The two forms are form.php and formcheck.php. Formcheck.php however is throwing me for a loop for several days now! I can get everything to work with one exception of a variable from form.php not being acceptable to formcheck.php. As a result, I've made the scripts as short as I can and still have them functional.

Form.php:

<PHP>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<title> Contact Form</title>
</head>
<body>
<html>
<?php
echo "<H1> Contact Form </H1>";
$a= mt_rand(nnn,nnn); // 'n'=Anydigit, + or -
$b= mt_rand(nnn,nnn);
$c= mt_rand(nnn,nnn);
$d=($a.$b.$c);
echo "Your Temporary Code is : " . $d."<br />" ;

?>

<form action="formcheck.php" method="post">
<p> Enter Your Temporary Code : </b> <input type="text" name="name" size="14 " maxlength="12"> including dashes. <br />
<p> <input type="submit" value="Send e-mail"> </p>
</form>
</body>
</html>

</PHP>

Like I said there seems to be no problems there that I can detect. But, I reveive an error message fro formcheck.php when it's run, called by form.php.

formcheck.php:

<PHP>

<?php
/ Set e-mail recipient /
$myemail = "me@example.net";
echo "E-mail: ".$myemail."<br />";
$code=($_POST['code']);
echo $code;
?>

</PHP>

The response and message I receive is:

"
E-mail: web-master@hcs-classof64.net

Notice: Undefined index: code in C:\xampp\htdocs\formcheck.php on line 7
"

It makes no sense to me and though it's a "notice", it stops anything else from working. I don't understand what the warning means.by undefined index.🙁

Line 7 is "$code=($_POST['code']);", for rference.

Lines 7 and 8 then are the lines of concern, I think. I do have eALL BTW.

ANY advice, explanation , clarification , etc. will be most appreciated! I know it's something stupid on my part, but ... help, please! lol

TIA,

Rivet

    There is no field in your form named "code". So [font=monospace]$_POST['code'][/font] is undefined.

      GAK! That was dumb of me!

      It works now of course.

      Apologies for such a stoopid question!

      Best Regards,

      Rivet

        Write a Reply...