• Resolved oweskeez

    (@oweskeez)


    Here is a link to the page in question: https://www.bigapplebuddy.com/quick-quote/

    This is my form:

    <form id="quick-quote" class="" action="" method="post">
      <label>Country</label>
      <br>
      <input id="country" type="text" name="country" value="">
      <br>
      <label>Postal Code</label>
      <br>
      <input id="postal" type="text" name="postal" value="">
      <br>
      <br>
      <input id="submit" type="submit" name="" value="submit">
    </form>
    <br>

    This is my php script directly under the form (same file):

    <?php
      print_r($_POST);
      error_reporting(E_ALL);
      session_start();
    
      require_once('../../library/fedex-common.php');
    //a bunch of functions that use the form data go here
    ?>

    I then include the above file in a template file so I can call it on specific pages:

    <?php /* Template Name: quick-quote */ ?>
    
    <?php
    get_header();
    
    include('RateService_v20_php/RateAvailableServicesService_v20_php/php/RateWebServiceClient/RateAvailableServices/RateAvailableServicesWebServiceClient.php');
    
     get_footer();
     ?>
    

    The issue that I have having is this:
    -I fill out the form
    -hit submit
    -print_r($_POST) the data to see if form posted correctly (it does)
    -any code after require_once(‘../../library/fedex-common.php’); does not execute

    Things I have already checked/tried:
    -PHP and SOAP are installed correctly on the server
    -all files are excessible 664 not 666
    -ran the file on the server, it works fine
    -setting the form’s action to “rate.php” or “quick-quote.php” (form posts data to same page so I think this can be left blank)
    -made sure (‘../../library/fedex-common.php’) is the correct path

    So my questions are:
    -How do I make the php script execute after the form is submitted?
    -Is this accomplished using functions.php to hook into admin-post.php?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Is the above code part of a theme template page or part of a plugin? To work in WordPress, it would really need to be the latter.

    Thread Starter oweskeez

    (@oweskeez)

    Esmi,

    Thanks for the response. I am using a template file as I only want this feature on certain pages. Can I accomplish this with a plugin? Why does wordpress require a plugin to execute php code after a form is submitted? Seems to complicate a rather simple process.

    Thread Starter oweskeez

    (@oweskeez)

    @esmi thank you so much! I wrote my own plugin and the form and script work perfectly!

    Cool! ??

    Now that you’ve written your first plugin, you should be able to go on and create plugins for whatever you want. Or grab suitable plugins from www.remarpro.com and modify them to better suit your needs.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP script not executing after form submit’ is closed to new replies.