SirChick Posted January 13, 2008 Share Posted January 13, 2008 I have a form as below: <form name="" method="POST" action="frozenaccountprocess.php?ID=<?=$ID?>" id="Form1" onsubmit="return ValidateForm1(this)"> <textarea name="TextArea1" rows="10" cols="55"></textarea><br><br> <input type="submit" name="Submit" value="Submit Response"><br><br><br> </form> Then on frozenaccountprocess.php i have put: <?php If(isset($_POST['Submit'])){ echo 'test1'; }Else{ echo 'test2'; } ?> but i keep getting test2 echo'd rather than test1... why is that what did i do wrong ?1 Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/ Share on other sites More sharing options...
Hypnos Posted January 13, 2008 Share Posted January 13, 2008 Glancing over your code, it looks right. Can you try putting var_dump($_POST); on the top of frozenaccountprocess.php, and tell us what the output is? Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438016 Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 array(0) { } What ever that means ? lol Presuming it means nothing is being sent across? Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438018 Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 It means your form data isn't reaching your script properly. Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438020 Share on other sites More sharing options...
nikefido Posted January 13, 2008 Share Posted January 13, 2008 could be your javascript...are you returning True if it validates in your javascript? Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438021 Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 could be your javascript...are you returning True if it validates in your javascript? I dont have any JS. I am wondering if its the <From> tag in the html ? Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438024 Share on other sites More sharing options...
Hypnos Posted January 13, 2008 Share Posted January 13, 2008 onsumbit is a javascript event. Take out that part of the form tag. <form name="" method="POST" action="frozenaccountprocess.php?ID=<?=$ID?>" id="Form1"> Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438027 Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 Argh working now! Thanks! What does the javascript event do that exactly i always assumed it was always needed Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438029 Share on other sites More sharing options...
nikefido Posted January 13, 2008 Share Posted January 13, 2008 looks to me like it calls a custom fuction to validate the fields (function named "ValidateForm1") If it returns True, the form is submitted. If it returns False, the form will not be submitted. It was probably returning False or just creating an error and breaking your form. Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438031 Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 The onsubmit handle was calling a javascript function when the form is about to be submitted. It looks like the function was meant to check the form was filled in properly and then either stop the form submitting (if the form was filled out incorrectly) or allow the form to submit normally. You presumably didn't have that function defined and so it was always returning false and therefore not submitting. Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438033 Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 Oh i see why now. Some one was helping me with forms and i told him i was going to add JS validation later on so he must of put that tag into the form attribute for me to deal with later on. I then changed my mind cos people can turn JS off so was wasted time coding. Then just assumed that onsubmit was part of html lol ! Thanks for the help though guys! Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438045 Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 Yeah people can turn it off but most either don't know how or just don't. Either way, the javascript validation is good for useability as people can be told of slight errors without having to load another page, be told that there were errors and they go back and change them. You shouldn't rely on javascript to do your validation for you though. Validate with javascript and PHP if you can. Quote Link to comment https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/#findComment-438084 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.