PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm trying to basic PHP code here but I got this error
Undefined Index Error.
Would somebody give me some hints about where to correct to make this code working fine without any error ?
here is the code
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The first time you run the code no form value has been input therefore $_REQUEST['opt'] does not exist.
I would simple use an if then else statement to check if $_POST has been sent. If it has then process with a switch if you have more than one option. with the else outputting the form when the form has not been sent.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm sorry guys, I have an additional enquiries about expending this code.
If I have a list of code as following:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
You will always get an undefined index notice when you attempt to use a var that a) has an index and b) the index has not yet been given a value. Imagine this code:
What is the value of $myarray['myindex']? Who knows? The fact that there is not known value for it is what the PHP engine is squawking about. Now look at this code: