I work on a 'play play server' on my pc, for lack of a real server, for this I use WampServer, I have recently updated my version. I suspect its running PHP5 - and Im used to PHP4 behaviour...

Most of the pages I use forms on have the page name as the action <form method="post" action="adduser.php"> - where adduser.php is the page the form is on.

At the top of my code I would have some if statements to process inputted data, if the submit button had been clicked

        //save data etc

but now I get an error for each of these if statements :
Notice: Undefined index: save in C:\wamp\www\crossfire\www\admin\prod.php on line 5

Can anyone advise me on how to get around this?


Recommended Answers

All 8 Replies

you could try
if($HTTP_POST_VARS["save"] )

No, your $_POST is correct. The notice is given when the specified variable is not set. If you want to remove the notice you should use something like this:


Thanks guys, appreciate the feedback!

Just as a matter of interest, is this a PHP5 change?

No, it isn't, probably your settings have changed. In the php.ini you can disable notices from showing up. Probably that has been the case up until now.

thank you for the information above .. I really need this information to complete my website, thank you once again

In general it's best practice to use isset to make sure that your variables actually exist. I ran into this same exact problem months ago and it was a great learning experience.

isset should almost always be used, you should init your vars as well. you can init your vars to NULL then use isset in your form handling or init your vars to an empty string (= '') and check for an empty string in your form handling; or a combo of all the above.
if(isset($_POST && $_POST !== ''))

hey guys, I need to build a search engine for a website. We use PHP no database.
We have oevr 4000 pages and we often add and remove pages.
I know that database would be the best way to go, but we don't have access to it.
I'll appreciate help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.