Surely a foolish error, but I can't see it

Posted by dnagirl on Stack Overflow See other posts from Stack Overflow or by dnagirl
Published on 2010-04-21T15:06:57Z Indexed on 2010/04/21 15:13 UTC
Read the original article Hit count: 238

Filed under:
|
|
|

I have a form (greatly simplified):

<form action='http://example.com/' method='post' name='event_form'>
  <input type='text' name='foo' value='3'/>
  <input type='submit' name='event_submit' value='Edit'/>
</form>

And I have a class "EventForm" to process the form. The main method, process() looks like this:

public function process($submitname=false){
    $success=false;
    if ($submitname && isset($_POST[$submitname])){ //PROBLEM:  isset($_POST[$submitname] is always FALSE for some reason
        if($success=$this->ruler->validate()){//check that dependancies are honoured and data types are correct
            if($success=$this->map_fields()){//divide input data into Event, Schedule_Element and Temporal_Expression(s)
                $success=$this->eventholder->save();
            }
        }
    } else {//get the record from the db based on event_id or schedule_element_id
        foreach($this->gets as $var){//list of acceptable $_GET keys
            if(isset($_GET[$var])){
                if($success= $this->__set($var,$_GET[$var])) break;
            }
        }
    }
    $this->action=(empty($this->eventholder->event_id))? ADD : EDIT;
    return $success;
}

When the form is submitted, this happens: $form->process('event_submit'); For some reason though, isset($_POST['event_submit']) always evaluates to FALSE. Can anyone see why?

© Stack Overflow or respective owner

Related posts about php

Related posts about html