kapil@phpfreaks Posted March 23, 2012 Share Posted March 23, 2012 Hi I am new in PHP scripting. I wrote a small script but stuck in the below error message.. Can someone please correct the code? Thanks in advance. Kapil Notice: Undefined index: submitbutton in C:\xampp\htdocs\index.php on line 30 Error in code <?php echo "<title>PHP File Upload </title>"; $form = "<form action='index.php' method='POST' enctype='multipart/form-data'> <table> <tr> <td>Title : </td> <td><input type = 'text' name = 'title'> </td> </tr> <tr> <td>Description : </td> <td><textarea name ='description' cols ='35' rows = '5'> </textarea></td> </tr> <tr> <td> </td> <td><input type = 'file' name = 'myfile'> </td> </tr> <tr> <td> </td> <td><input type = 'submit' name ='submitbutton' value ='Submit'></td> </tr> </table> </form>"; if($_POST['submitbutton']) { $name = $_FILES['myfile']['name']; echo "$name"; } else { echo "Error in code"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/259541-undefined-index/ Share on other sites More sharing options...
darkfreaks Posted March 23, 2012 Share Posted March 23, 2012 there is NO name field do you mean $_FILES['myfile']['title']; Quote Link to comment https://forums.phpfreaks.com/topic/259541-undefined-index/#findComment-1330425 Share on other sites More sharing options...
kapil@phpfreaks Posted March 23, 2012 Author Share Posted March 23, 2012 Hmm.. thats other mistake Actually Im facing issue in piece of code :- if($_POST['submitbutton']) Quote Link to comment https://forums.phpfreaks.com/topic/259541-undefined-index/#findComment-1330428 Share on other sites More sharing options...
darkfreaks Posted March 23, 2012 Share Posted March 23, 2012 if(isset($_POST['button'])) { //insert code here }else { //insert error here } Quote Link to comment https://forums.phpfreaks.com/topic/259541-undefined-index/#findComment-1330429 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.