Jump to content

[SOLVED] Form $_POST undefined error with a disabled form.


Eggzorcist

Recommended Posts

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>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.