|
Posted by Janwillem Borleffs on 10/10/88 11:27
Andy wrote:
> OK.But I am not programmer and do not know how to fix my script.
> Could you check it and find what is wrong ?
>
I'll give you an example. The first notice was the following:
Notice: Undefined variable: to in c:\easyphp1-8\www\test.02\mail.php on line
37
This means that you're referencing a variable with the name $to, which isn't
defined. Now look at the referenced line:
$to = $to;
Obviously, $to isn't defined before this line, hence the notice. With your
error_reporting level adjustment fix, it will be defaulted to an empty
value, which is not very useful. When you change this into:
$to = 'recepient@example.com';
This problem will be fixed and $to will be set to something useful (when the
recepient's email address exists, of course).
Now, I'm guessing that $to and all the other variables originate from a
form. This scripts relies on a directive called register_globals being
enabled and this isn't the case anymore since PHP v4.1. From this version
on, this directive is disabled by default and you should use the so-called
superglobals $_GET, $_POST or $_REQUEST for handling form data.
More information on the register_globals and the use of superglobals can be
found at:
http://www.php.net/manual/en/security.globals.php
Now, when you change the assignment of the $to variable into:
$to = $_REQUEST['to'];
The $to variable will be properly assigned *if* the equally named form field
actually is sent to the script. Otherwise, you will get another notice.
Although this notice can be suppressed prepending an at-sign (@) to the
assignment or you can test with the isset() function if it's set, you will
have to decide what you want to do when it's empty. Do you want to use a
default, throw an error message or just continue?
When you have made your mind up how to handle cases like this, you will need
to implement it. Of course, you can check this newsgroup for people willing
to do it for you, but changes are that you will only be flamed in the best
case.
Show that you want to put some effort in it and learn at least the basics of
the PHP language. The language is very user friendly to new users, so don't
be afraid.
Start your training at the following page:
http://www.php.net/manual/en/tutorial.php
Good luck!
JW
Navigation:
[Reply to this message]
|