Eggzorcist Posted August 10, 2009 Share Posted August 10, 2009 I'm unsure why this is happening, but it seems like the form isn't defining my $_POST which are disabled form. The reason it is disabled it is because the previous field is a ajax which auto fills the next one. but it seems its not defining that post because of that... here's my forms. <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"/> <p> Event TItle:<br /> <input type="text" name="title" id="title" /> <br /> <br /> From: </p> <p> <input name="datepicker1" type="text" id="datepicker1" value="Click here to select a date."/> <input type="text" disabled="disabled" id="alternate1" size="30"/> <br /> </p> <p>Event starts at: <em> <input name="timestart" type="text" id="timestart" size="15" /> </em><br /> <br /> To:</p> <p> <input type="text" id="datepicker2" value="Click here to select a date."/> <input type="text" disabled="disabled" id="alternate2" size="30"/> <br /> </p> <p>Event finishes at: <em> <input name="timefinish" type="text" id="timefinish" size="15" /> </em><br /> <br /> Quick Event Description:<br /> <textarea name="Qdescription" cols="30" rows="4" id="Qdescription"></textarea> <br /> <br /> Event Page Description:<br /> <textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 50%" class="tinymce"></textarea> <br /> <br /> <input type="submit" name="save" value="Submit" id="submit" /> <input type="reset" name="reset" value="Reset" /> </p> </p> </form> Quote Link to comment Share on other sites More sharing options...
halfman Posted August 10, 2009 Share Posted August 10, 2009 Mate, the description is very unclear. can you please explain more? I cant see any problem with this form. can you put the php or the ajax response too, so I can investigate it for you?. Cheers Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 10, 2009 Author Share Posted August 10, 2009 well this is the error I get. Notice: Undefined index: alternative1 in /Users/JPFoster/Sites/Event_Profiler/addevent.php on line 6 Notice: Undefined index: alternative2 in /Users/JPFoster/Sites/Event_Profiler/addevent.php on line 6 My php is if($_POST){ addeventToPending($_POST['title'], $_POST['datepicker1'], $_POST['alternative1'], $_POST['timestart'], $_POST['datepicker1'], $_POST['alternative2'], $_POST['timefinish'], $_POST['Qdescription'], $_POST['elm1']); } everything works well until it hits that erorr. The only thing that is different about those two variables is that it's a disabled field... Do I have to make it an active field? Because I really don't want to give people the option to change it. Thanks Quote Link to comment Share on other sites More sharing options...
halfman Posted August 10, 2009 Share Posted August 10, 2009 check your variables and see if you declare them? also you can diable the notice warning in your error_reporting Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 11, 2009 Author Share Posted August 11, 2009 Well when I diable the notice, it doesn't define that variable. There's nothing different than any other of my variable but the it is a disabled field. I believe this is what's causing the problem. Is there a way to use a disabled field as $_POST variable? Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 11, 2009 Author Share Posted August 11, 2009 Okay I tried changing one to an enabled form and it gives me the same results... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 12, 2009 Author Share Posted August 12, 2009 I seems like becausing I'm using javascript to load the data in those fields it doesn't set them properly... Does anyone know what to do to fix this problem? Quote Link to comment Share on other sites More sharing options...
play_ Posted August 12, 2009 Share Posted August 12, 2009 Yea, look like disabled form fields have no $_POST values. You're not solely relying on a disabled form field to prevent users from submitting the data they want, are you? Getting around a disabled form field is extremely easy. One could just open firebug and delete the 'disabled' part. Maybe hidden values here can help? hth Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 13, 2009 Author Share Posted August 13, 2009 Well I'm making it disabled because it's connected to an javascript form, so depending what you put in field1, it will automatically fill in field2... So I'd like to keep it disabled. I've also tried to change it without the disabled and still did not value that specific $_POST. Quote Link to comment Share on other sites More sharing options...
play_ Posted August 13, 2009 Share Posted August 13, 2009 Probably because you didnt give it a value. i used the following code <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="text" disabled="disabled" name="username" value="johnDOE" /> <input type="submit" value="send" name="submit" /> </form> <?php if( isset($_POST['submit']) ) { print_r($_POST); } ?> the only $_POST value i get when i hit submit is 'submit'. If i take out the disabled though, i do get 'johnDOE'. maybe what you need to do is, insert a whole field instead of disabling/enabling them (hopefully youre using jquery for this) Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 13, 2009 Author Share Posted August 13, 2009 Perfect, I didn't know I needed to assign a value to it, works great. Thanks a lot for a quick easy solution! Quote Link to comment Share on other sites More sharing options...
play_ Posted August 13, 2009 Share Posted August 13, 2009 No prob. Quote Link to comment 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.