tarun Posted March 16, 2007 Share Posted March 16, 2007 Ive Had Previous Help With This But Now Theres ANOTHER Problem: The Form Wont Submit - Why? Please Help Me Thnx Heres My Source Code <?php $addform = "<form name='addvideo' action='$PHP_SELF' method='post'> Video URL:<BR><input type='text' name='url' size='40'> <br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form> <input type='submit' value='Submit'>"; echo "$addform"; if (isset($_POST['Submit'])) { $url = $_POST['url']; $desc = $_POST['desc']; if(empty($url)){ echo "Please Specify The URL Of The Video<br>"; } elseif(empty($desc)){ echo "Please Specify A Description Of The Video<br>"; } else{ $newcontent = "<videos> <video url='$url' desc='$desc' /> </videos>"; $previouscontent = file_get_contents("videoplaylist.xml"); $openfile = fopen("videoplaylist.xml", "w"); $totalfile = $previouscontent.$newcontent; fwrite($openfile, $totalfile); fclose($openfile); echo "File Added To Playlist<br><br>Add A New File?<br>$addform"; } } ?> Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/ Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 <?php $PHP_SELF = $_SERVER['PHP_SELF']; $addform = "<form name='addvideo' action='$PHP_SELF' method='post'> Video URL:<BR><input type='text' name='url' size='40'> <br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form> <input type='submit' value='Submit'>"; echo "$addform"; if (isset($_POST['Submit'])) { $url = $_POST['url']; $desc = $_POST['desc']; if(empty($url)){ echo "Please Specify The URL Of The Video<br>"; } elseif(empty($desc)){ echo "Please Specify A Description Of The Video<br>"; } else{ $newcontent = "<videos> <video url='$url' desc='$desc' /> </videos>"; $previouscontent = file_get_contents("videoplaylist.xml"); $openfile = fopen("videoplaylist.xml", "w"); $totalfile = $previouscontent.$newcontent; fwrite($openfile, $totalfile); fclose($openfile); echo "File Added To Playlist<br><br>Add A New File?<br>$addform"; } } ?> Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-208970 Share on other sites More sharing options...
tarun Posted March 16, 2007 Author Share Posted March 16, 2007 By The Way What Did You Change Because It Still Doesn't Work Any More Help Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-208976 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 $PHP_SELF shouldn't work without defining it first. <?php $PHP_SELF = $_SERVER['PHP_SELF']; $addform = "<form name='addvideo' action='$PHP_SELF' method='post'> That was what I changed above. <?php $PHP_SELF = $_SERVER['PHP_SELF']; $addform = "<form name='addvideo' action='$PHP_SELF' method='post'> Video URL:<BR><input type='text' name='url' size='40'> <br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form> <input type='submit' value='Submit' name="Submit"></form>"; echo "$addform"; if (isset($_POST['Submit'])) { $url = $_POST['url']; $desc = $_POST['desc']; if(empty($url)){ echo "Please Specify The URL Of The Video<br>"; } elseif(empty($desc)){ echo "Please Specify A Description Of The Video<br>"; } else{ $newcontent = "<videos> <video url='$url' desc='$desc' /> </videos>"; $previouscontent = file_get_contents("videoplaylist.xml"); $openfile = fopen("videoplaylist.xml", "w"); $totalfile = $previouscontent.$newcontent; fwrite($openfile, $totalfile); fclose($openfile); echo "File Added To Playlist<br><br>Add A New File?<br>$addform"; } } ?> I changed the : <input type='submit' value='Submit' name="Submit"></form>"; this time around, see if that works. Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-208978 Share on other sites More sharing options...
tarun Posted March 16, 2007 Author Share Posted March 16, 2007 I Found The Problem <br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form> <input type='submit' value='Submit' name='Submit'></form>"; There Were Two /form Tags Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-208982 Share on other sites More sharing options...
shaunrigby Posted March 16, 2007 Share Posted March 16, 2007 Plus, i don't know if it is true, but if you press enter(rather than clicking submit), Submit is not defined, a safer option would be to use: <input type="hidden" name="submitted" value="true"> Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-209024 Share on other sites More sharing options...
tarun Posted March 17, 2007 Author Share Posted March 17, 2007 Aright Then Thnx Every One TOPIC SOLVED!!! Link to comment https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/#findComment-209415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.