If you are arriving at this page via a post request than, the code in
the if statement will get run. I would recommend the following:
if($request->isMethod('post') && $request->hasParameter($form-
>getName())){
//code code code
}
Obviously, that will only get run when the form is posting to this
page and since their aren't any magic words, it is fairly
maintainable.
HTH,
Casey
On May 7, 5:29 pm, Parijat Kalia <[email protected]> wrote:
> Yes, that it is. It is being redirect to from the login page ...the login
> page is a post, and then if the credentials are verified
> I use this
>
> $this->redirect(thisModule/thisPage)
>
> but it is kind of strange that a post from another page is being redirected
> here, because the post on the login page posts onto itself,
>
>
>
> On Fri, May 7, 2010 at 9:39 AM, Casey <[email protected]> wrote:
> > So when you navigate to the page, in what shou;d be a get request,
> > without submitting the form, the var_dump call dumps true? If that is
> > the case than there is something going on that is probably not symfony
> > related. It is possible to create link with symfony that will call
> > the page in a post request, maybe wherever you are coming to the page
> > from is doing some kind of post request to your current page. From
> > what I can tell the code looks good, although I would recommend the
> > use of $request->getParameter and $user->getAttribute instead of $_GET
> > and $_SESSION.
>
> > HTH,
> > Casey
>
> > On May 6, 9:57 am, Parijat Kalia <[email protected]> wrote:
> > > All right...it did post a bool, that is true....which has been the
> > > case...here is the action....I am posting only until the
> > > if($this->getRequest()->isMethod('post')) line...after that it's just
> > code
> > > execution...the template code follows after the action
>
> > > * public function executeCreateQuestions()
> > > {
> > > $this->user = $_SESSION['user'];
> > > $username = $_SESSION['user'];
> > > $configs = new Criteria();
> > > $configs->add(ConfigurationsPeer::GROUP_ID,1);
> > > $configurations = ConfigurationsPeer::doSelect($configs);
>
> > > if($configurations == null)
> > > {
> > > // redirect to the configurations not loaded page.
> > > }
>
> > > else
> > > {
> > > foreach($configurations as $configuration)
> > > {
> > > $courseTitle = $configuration->getCourses();
> > > $topics_as_array = $configuration->getTopics();
>
> > > $topics_levels= explode(",",$topics_as_array);
> > > $options_for_select = array();
> > > $topics_for = $courseTitle.' topics';
> > > $levels_for = '';
> > > foreach($topics_levels as $topic_level){
>
> > > $topic_level_as_string =
> > > (string)$topic_level;
> > > $splits = explode("-",$topic_level_as_string);
>
> > > $topics_for= $topics_for.','.$splits[0];
> > > $levels_for = $levels_for.','.$splits[1];
>
> > > }
> > > $options_for_select = explode("," , $topics_for);
> > > $levels_for_select = explode("," , $levels_for);
>
> > > $this->topic_options = $options_for_select;
> > > $this->level_options = $levels_for_select;
>
> > > }
>
> > > }
> > > if(isset($_GET['qId']))
> > > {
> > > $updateQuestionId = $_GET['qId'];
> > > $uc = new Criteria();
> > > $uc->add(QuestionsPeer::ID,$updateQuestionId);
> > > $this->updateRecords = QuestionsPeer::doSelect($uc);
> > > }
>
> > > if($username == '')
> > > {
> > > $this->redirect('user/login');
>
> > > }
>
> > > var_dump($this->getRequest()->isMethod('post'));
> > > if(($this->getRequest()->isMethod('post'))) // The action takes
> > place
> > > when the Submit button is hit.
> > > { *
>
> > > TEMPLATE
>
> > > *<?php use_helper('Form') ?>
> > > <?php echo include_stylesheets() ?>
> > > <?php
> > > ?>
>
> > > <script type="text/javascript">
>
> > > function visibilitySwitch()
> > > {
> > > var id_of_element = document.getElementById('answer-type');
> > > var user_choice =
> > > id_of_element.options[id_of_element.selectedIndex].value;
> > > var choice1 = "multiChoiceSingleCorrect";
> > > var answer_options_id_2 = document.getElementById('true-false');
> > > var answer_options_id =
> > document.getElementById('multiple-choice');
>
> > > if(user_choice == "2")
> > > {
> > > answer_options_id.setAttribute("class","visible");
> > > answer_options_id_2.setAttribute("class","display");
> > > }
>
> > > if(user_choice == "3")
> > > {
> > > answer_options_id_2.setAttribute("class","visible");
> > > answer_options_id.setAttribute("class","display");
> > > }
>
> > > }
>
> > > function expand(id)
> > > {
> > > var e = document.getElementById(id).style.height;
> > > e = parseInt(e.replace("px",""));
> > > if (isNaN(e)) {
> > > e = 250;
> > > }
> > > e += 30;
> > > document.getElementById(id).style.height = e + "px";}
>
> > > function contract(id)
> > > {
> > > e = document.getElementById(id).style.height;
> > > e = parseInt(e.replace("px",""));
> > > if (isNaN(e)) {
> > > e = 250;
> > > }
> > > if (e > 250) {
> > > e -= 30;
> > > document.getElementById(id).style.height = e + "px";
> > > }}
>
> > > function userPressedEnter(e)
> > > {
>
> > > if(e.keyCode == 13 )
> > > {
> > > textarea = document.getElementById("question_box");
> > > currentText = textarea.value;
> > > textarea.value = currentText+"<br>";
>
> > > }
>
> > > }
>
> > > function rs_txt_box(name, col_inc, row_inc)
> > > {
> > > var obj = document.getElementById(name);
>
> > > obj.rows += row_inc;
> > > obj.cols += col_inc;
> > > }
>
> > > function insertLines()
> > > {
>
> > > var questionboxArea = document.getElementById("question_box");
> > > var choice1 = document.getElementById("option_1");
> > > var choice2 = document.getElementById("option_2");
> > > var choice3 = document.getElementById("option_3");
> > > var choice4 = document.getElementById("option_4");
>
> > > val = questionboxArea.value;
> > > questionboxArea.value = val.replace(/\n/gi,"\n");
>
> > > /* Text areas appear as options for multiple type single answer
> > > choices, in that event, perform the insertLines operation*/
> > > questionType = document.getElementById("answer-type");
> > > userChoice = questionType.value;
>
> > > if(userChoice == 2)
> > > {
> > > val1 = choice1.value;
> > > val2 = choice2.value;
> > > val3 = choice3.value;
> > > val4 = choice4.value;
>
> > > choice1.value = val1.replace(/\n/gi,"\n");
> > > choice2.value = val2.replace(/\n/gi,"\n");
> > > choice3.value = val3.replace(/\n/gi,"\n");
> > > choice4.value= val4.replace(/\n/gi,"\n");
> > > }
>
> > > }
>
> > > </script>
>
> > > <p><font color="red"><?php if(isset($unselectedFields)){ echo
> > > $unselectedFields;}echo "<br>"; if(isset($noQuestionMessage)){echo
> > > $noQuestionMessage;}?></font></p><br>
> > > <?php echo form_tag('questions/createQuestions',
> > > Array('multipart'=>true)) ?>
>
> > > <table border="5" cellspacing="1" cellpadding="2" class="table">
> > > <tr>
> > > <td>TOPIC </td><td>QUESTION-ANSWER TYPE </td><td> ALLOCATE
> > > POINTS</td><td> TIME LIMIT</td>
> > > </tr>
> > > <tr>
> > > <td align="center">
> > > <?php echo select_tag('topics_to_choose',
> > > options_for_select($topic_options))?>
> > > </td>
> > > <td>
> > > <?php echo
> > > select_tag('answer-type',options_for_select(array(1=>'Question-answer
> > type',
> > > 2=>'Multiple-choice single correct answer', 3=>'True or False')),
> > > array('onChange'=>'Javascript:visibilitySwitch()') ) ?>
> > > </td>
> > > <td align="center">
> > > <?php echo
> > select_tag('answer-points',options_for_select(array(1=>'1',
> > > 2=>'2', 3=>'3', 4=>'4', 5=>'5', 6=>'6', 7=>'7', 8=>'8', 9=>'9',
> > 10=>'10')) )
> > > ?>
> > > </td>
> > > <td align="center">
> > > <?php echo
>
> > select_tag('time_mins',options_for_select(array(1=>'0',2=>'1',3=>'2',4=>'3'
> > ,5=>'4',6=>'5',7=>'6')));
> > > ?>
> > > <b>:</b>
> > > <?php echo
>
> > select_tag('time_secs',options_for_select(array(1=>'00',2=>'01',3=>'02',4=>
> > '03',5=>'04',6=>'05',7=>'06',8=>'07',9=>'08',10=>'09',11=>'10',
>
> > 12=>'11',13=>'12',14=>'13',15=>'14',16=>'15',17=>'16',18=>'17',19=>'18',20=
> > >'19',21=>'20',22=>'21',23=>'22',24=>'23',23=>'24',24=>'25',25=>'26',26=>'2
> > 7',
>
> > 27=>'28',28=>'29',29=>'30',30=>'31',31=>'32',32=>'33',34=>'35',35=>'36',36=
> > >'37',37=>'38',38=>'39',39=>'40',40=>'41',42=>'43',43=>'44',44=>'45',45=>'4
> > 6',
>
> > 46=>'47',47=>'48',48=>'49',49=>'50',50=>'51',52=>'53',53=>'54',55=>'56',57=
> > >'58',58=>'59',59=>'60')));
> > > ?>
> > > </td>
>
> > > </tr>
> > > </table>
> > > <br>
>
> > > <br>
>
> > > <?php echo input_file_tag('image_question') ?>
>
> > > <a onclick="javascript:rs_txt_box('question_box', 5, 0);"
> > > href="javascript://">
> > > <img style="margin: 2px;" src="/images/rs_right.gif" alt=""/>
>
> > > <a onclick="rs_txt_box('question_box', 0, 10);" href="javascript://">
> > > <img style="margin: 2px;" src="/images/rs_down.gif" alt=""/>
>
> > > <a onclick="rs_txt_box('question_box', -5, 0);" href="javascript://">
> > > <img style="margin: 2px;" src="/images/rs_left.gif" alt=""/>
>
> > > <a onclick="rs_txt_box('question_box', 0, -10);" href="javascript://">
> > > <img style="margin: 2px;" src="/images/rs_up.gif" alt=""/>
>
> > > <?php echo textarea_tag('question_box',' ','size=105x4'); ?>
>
> > > <p><font color="red"><?php if(isset($errorMessage)){ echo $errorMessage;}
> > > ?></p></font>
> > > <br><br>
> > > <p> <font color="black"><b>ANSWER CHOICES(mark the correct
> > > answer)</b> </font></p>
> > > <br>
>
> > > <div id="true-false" class="invisible">
> > > True <?php echo radiobutton_tag('true_false', 'true',
> > > false) ?> <br>
> > > False<?php echo radiobutton_tag('true_false', 'false',
>
> ...
>
> read more »
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en