cdmafra Posted March 24, 2014 Share Posted March 24, 2014 (edited) Hello. I have a undefined index problem: Notice: Undefined index: submit in C:\wamp\www\mrn_site\login\index3.php on line 106 <?php function clear($message) { if(!get_magic_quotes_gpc()) $message = addslashes($message); $message = strip_tags($message); $message = htmlentities($message); return trim($message); } if ($_POST['submit']) /** LINE 106 **/ { if (empty($_POST['news_title'])) die('Falta o título'); else if (empty($_POST['news_subtitle'])) die('Falta o subtítulo'); else if (empty($_POST['news_post'])) die('Falta o post'); $news_title = clear($_POST['news_title']); $news_subtitle = clear($_POST['news_subtitle']); $news_post = clear($_POST['news_post']); $date = time(); mysql_connect('localhost','root'); mysql_select_db('944273_mrn'); if(mysql_query("INSERT INTO news (news_title , news_subtitle, news_post , news_date) VALUES ('$news_title', '$news_subtitle', '$news_post', '$date')")) echo 'News Entered.'; mysql_close(); } ?> <!--FIM DE SCRIPTS--> </head> <body > <form method="post" action="#"> Posted By:<br /><input name="news_title" id="news_title" type="Text"><br /> Subject:<br /><input name="news_subtitle" id="news_subtitle" type="Text"><br /> <textarea name="news_post" id="news_post" cols="50" rows="5"></textarea><br /> <input type="submit" name="submit" id="submit" value="Enter News"> </form> </body> </html> Edited March 24, 2014 by cdmafra Quote Link to comment https://forums.phpfreaks.com/topic/287229-undefined-index/ Share on other sites More sharing options...
Solution Ch0cu3r Posted March 24, 2014 Solution Share Posted March 24, 2014 Use isset on that var if (isset($_POST['submit'])) Quote Link to comment https://forums.phpfreaks.com/topic/287229-undefined-index/#findComment-1473681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.