cdmafra Posted March 24, 2014 Share Posted March 24, 2014 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> Link to comment https://forums.phpfreaks.com/topic/287229-undefined-index/ Share on other sites More sharing options...
Ch0cu3r Posted March 24, 2014 Share Posted March 24, 2014 Use isset on that var if (isset($_POST['submit'])) Link to comment https://forums.phpfreaks.com/topic/287229-undefined-index/#findComment-1473681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.