hello friends i am new in php ,want to add form with database ,but a error appeared ,
( ! ) Notice: Undefined variable: name in C:\wamp\www\your_mail\register.php on line 26 Call Stack # Time Memory Function Location 1 0.0521 142664 {main}( ) …\register.php:0
( ! ) Notice: Undefined variable: email in C:\wamp\www\your_mail\register.php on line 26 Call Stack # Time Memory Function Location 1 0.0521 142664 {main}( ) …\register.php:0
Your SQL query isn’t inside your if statement, so if those $name and $email variables aren’t set, PHP outputs a notice error saying that it can’t find them. If you put the SQL statement inside the if statement, it should solve your problem.
isset() is a predicate language construct; it returns TRUE if the variable exists in memory, or FALSE if it does not. For a variable to exist, it must not have a NULL value. This means that anything but a NULL value (including empty values, ‘’) will result in isset() returning TRUE, causing the conditions within your IF statement to parse.
In your scenario above, you were checking that the element key, name, in the $_POST super global variable was set (i.e. PHP had loaded the contents of the HTTP POST data into $_POST for you to manipulate). It is important that you perform checks to ensure variables are set before trying to manipulate them (using isset()) to prevent notices and bugs from cropping up within your application.