Home › Forums › Quform WordPress › Re-Direct
- This topic has 9 replies, 3 voices, and was last updated 11 years, 6 months ago by
lawrencepepper.
- AuthorPosts
- November 6, 2013 at 7:31 pm #7275
lawrencepepper
ParticipantI am sending form data on a re-direct.
I placed the following code in my functions.php file.
function submit_form_redirect($url, $form)
{
$data = array(
'start' => $form->getValue('iphorm_4_1'),
'end' => $form->getValue('iphorm_4_2'),
);$data = array_map(‘rawurlencode’, $data);
$url = add_query_arg($data, ‘http://my.url.com’);
return $url;
}
add_action(‘iphorm_success_redirect_url_4’, ‘submit_form_redirect’, 10, 2);On the url that this form re-directs to how do I use the post variables sent.
I have used:
$_post[start]
$_form[start]
$_post[“start”]
$_form[“start”]None work.
What I want to do is then run a query using the values from the form that I am re-directing.
L
November 6, 2013 at 8:08 pm #7278lawrencepepper
ParticipantWell,
I found another way but still stuck.
I am using the following code to set session variables:
function submit_range($form)
{
$_SESSION['iphorm_4'] = $form->getValues();
}
add_action('iphorm_post_process_4', 'submit_range');I am passing a start date and an end date.
Then on the redirected page I am trying to run a query selecting data from my database between a date range using those two dates passed by the form.
On the reirected page I am setting the variables passed as so:
$start = $_SESSION[‘iphorm_4’][‘iphorm_4_1’];
$end = $_SESSION[‘iphorm_4’][‘iphorm_4_2’];Then running a query using them as so:
WHERE date BETWEEN ‘$start’ AND ‘$end’
But this does not work.
Any help?
L
November 6, 2013 at 8:21 pm #7279desseily
ParticipantIf you have the fields as as date value in your form, then the result is an array. Use a foreach statement to get year, month and day
November 6, 2013 at 8:27 pm #7280lawrencepepper
ParticipantPlease forgive me but my PHP is not all that great, could you give me some direction on how to do that or point me to an example on the web?
Just searched stack overflow but nothing really comes up for my example….
Thanks
L
November 6, 2013 at 8:50 pm #7281desseily
Participantsomething similar to this.
foreach($start as $key=>$value) {
echo ‘line ‘. $key.’/’. $value.'<br>’;
}
}November 7, 2013 at 9:19 am #7288Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
November 7, 2013 at 2:17 pm #7291lawrencepepper
ParticipantThanks Ally!
How can I have the day default to have a 0 in front of it is it is 9 or below:
2013-11-04
right now it is coming out
2013-11-4
L
November 7, 2013 at 2:26 pm #7292lawrencepepper
ParticipantSomething is now working right:
The second date being passed keeps coming up:
2013-2-02
No matter what I pick in the date picker on the form page.
The first always comes correct.
My code is:
$start = $_SESSION['iphorm_4']['iphorm_4_1'];
$start = $start['year'] . '-' . $start['month'] . '-' . $start['day'];$end = $_SESSION['iphorm_4']['iphorm_4_2'];
$end = $end['year'] . '-' . $start['month'] . '-' . $start['day'];
The start date always passes correctly but the end date keeps coming up 2013-02-12 no matter what I pick in the date picker on the form page.
my code in the functions.php file is:
function submit_range($form)
{
$_SESSION['iphorm_4'] = $form->getValues();
}
add_action('iphorm_post_process_4', 'submit_range');
November 7, 2013 at 2:28 pm #7293lawrencepepper
ParticipantOops!
I see….
did not change all values in the second $end line…
L
November 7, 2013 at 6:31 pm #7297lawrencepepper
ParticipantGot it all working.
Thanks!
L
- AuthorPosts
- You must be logged in to reply to this topic.