Forums

[resolved] Custom form (5 posts)

  1. spstieng
    Member
    Posted 6 months ago #

    I'm creating some custom pages which contains forms.

    In my wordpress file (myTempalte.php), I have the following code:

    (...)
          <div class="contentbox470px floatLeft">
            <h3><?php _e('ForeslÄ butikk','StoreLocator');?></h3>
            <?php include_once 'includes/storeLocator/frm_store.php' ?>
          </div>
          (...)

    My frm_store.php looks like this:

    <form id="store_data_form" class="appnitro"  method="post" action="includes/process_frm_store.php">
      <input id="store_name" name="store_name" type="text" maxlength="40" value=""/>
      <input id="store_street1" name="store_street1" class="textfield65pc" value="" maxlength="50" type="text">
      <input id="saveForm" class="submitButton" type="submit" name="save" value="Submit Form" />
      <input id="clearForm" class="clearButton" type="reset" name="clear" value="Reset form" />
    </form>

    My process_frm_store.php looks like this:

    <?php
      $myDB = new DAL();
      $myDB->connect();
    
      if (isset($_POST['save']))
      {
        $formData =  array(
          "name"=> mysql_real_escape_string($_POST['store_name']),
          "street1"=> mysql_real_escape_string($_POST['store_street1'])
        $result = $myDB->addNewStore($formData);
        echo $result;
      }
    ?>

    My SQL function looks like this:

    public function addNewStore($formData)
      {
        $sql ="INSERT INTO sl_store(name, street1, street2, zipcode_id, phone, fax, www, email, opening_hours, active, descriptionID)";
        $sql .="VALUES('".
        $formData['name']."',".
          $formData['street1']."')";
    
       $this->query_result = mysql_query($sql, $this->conn);
    
       if($this->query_result)
        return $this->query_result;
      else
        return "Insertion failed";
      }

    My problem is that nothing happends.
    Nothing is inserted into the database, and the function is not returning anything.

    Are there any better ways of doing this?

  2. spstieng
    Member
    Posted 6 months ago #

    To simplyfy my question:

    How do I go about storing information from a qustom form to a database?

  3. Shane G
    Member
    Posted 6 months ago #

    Hi,

    Please use this plugin which will helpful to resolve the case..

    http://www.deliciousdays.com/cforms-plugin/

    Thanks,

    Shane G.

  4. spstieng
    Member
    Posted 6 months ago #

    I'm already using cForms II for other stuff.
    But I fail to see how this may solve my problem.

    I need to process the from data with my own scripts, so the data is stored in my own tables.

  5. spstieng
    Member
    Posted 6 months ago #

    I've partly fixed this, by having action="".

    Then I moved the content of the process_frm_store.php, to the top of my form page.

    So for now, I'm setting this problem so 'solved'.

Reply

You must log in to post.

About this Topic