Re-Direct

Home Forums Quform WordPress Re-Direct

This topic is: resolved
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #7275
    lawrencepepper
    Participant

    I 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

    #7278
    lawrencepepper
    Participant

    Well,

    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

    #7279
    desseily
    Participant

    If 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

    #7280
    lawrencepepper
    Participant

    Please 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

    #7281
    desseily
    Participant

    something similar to this.

    foreach($start as $key=>$value) {
    echo ‘line ‘. $key.’/’. $value.'<br>’;
    }
    }

    #7288
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #7291
    lawrencepepper
    Participant

    Thanks 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

    #7292
    lawrencepepper
    Participant

    Something 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');

    #7293
    lawrencepepper
    Participant

    Oops!

    I see….

    did not change all values in the second $end line…

    L

    #7297
    lawrencepepper
    Participant

    Got it all working.

    Thanks!

    L

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy