• I wrote this form to make a front-end form fill in the table for the store locator plus plug-in.
    I need to take the sl_address and sl_city fields and have them geocode for sl_longitude and sl_latitude.

    also, the first time someone goes to the page it submits an empty line in my database table.

    I am newbie, so sorry if this very simple.

    <?php
    /* Template Name: Add Venue */
    get_header();
    ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

    <form id=”form1″ name=”form1″ method=”post” action=””>
    <input type=”hidden” name=”sl_id” id=”sl_id” />
    <br class=”clear” />
    <label for=”sl_store”>Venue</label><input type=”text” name=”sl_store” id=”sl_store” />
    <br class=”clear” />
    <label for=”sl_address”>Address</label><input type=”text” name=”sl_address” id=”sl_address” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_address2″ id=”sl_address2″ />
    <br class=”clear” />
    <label for=”sl_city”>City, State, Zip</label><input type=”text” name=”sl_city” id=”sl_city” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_state” id=”sl_state” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_zip” id=”sl_zip” />
    <br class=”clear” />
    <label for=”sl_country”>Country</label><input type=”text” name=”sl_country” id=”sl_country” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_latitude” id=”sl_latitude” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_longitude” id=”sl_longitude” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_tags” id=”sl_tags” />
    <br class=”clear” />
    <label for=”sl_description”>Description</label><textarea name=”sl_description” id=”sl_description” cols=”45″ rows=”5″></textarea>
    <br class=”clear” />
    <label for=”sl_email”>Email</label><input type=”text” name=”sl_email” id=”sl_email” />
    <br class=”clear” />
    <label for=”sl_url”>Website</label><input type=”text” name=”sl_url” id=”sl_url” />
    <br class=”clear” />
    <label for=”sl_hours”>Hours</label><textarea name=”sl_hours” id=”sl_hours” cols=”45″ rows=”5″></textarea>
    <br class=”clear” />
    <label for=”sl_phone”>Phone</label><input type=”text” name=”sl_phone” id=”sl_phone” />
    <br class=”clear” />
    <label for=”sl_fax”>Fax</label><input type=”text” name=”sl_fax” id=”sl_fax” />
    <br class=”clear” />
    <label for=”sl_image”>Image</label><input type=”file” name=”sl_image” id=”sl_image” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_private” id=”sl_private” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_neat_title” id=”sl_neat_title” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_linked_postid” id=”sl_linked_postid” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_pages_url” id=”sl_pages_url” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_pages_on” id=”sl_pages_on” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_option_value” id=”sl_option_value” />
    <br class=”clear” />
    <input type=”hidden” name=”sl_lastupdated” id=”sl_lastupdated” />
    <br class=”clear” />
    <input type=”submit” name=”sl_submit” id=”sl_submit” value=”Submit” />
    <br class=”clear” />
    </form>

    <?php //Post Params
    $sl_id = $_POST[‘sl_id’];
    $sl_store = $_POST[‘sl_store’];
    $sl_address = $_POST[‘sl_address’];
    $sl_address2 = $_POST[‘sl_address2’];
    $sl_city = $_POST[‘sl_city’];
    $sl_state = $_POST[‘sl_state’];
    $sl_zip = $_POST[‘sl_zip’];
    $sl_country = $_POST[‘sl_country’];
    $sl_latitude = $_POST[‘sl_latitude’];
    $sl_longitude = $_POST[‘sl_longitude’];
    $sl_tags = $_POST[‘sl_tags’];
    $sl_description = $_POST[‘sl_description’];
    $sl_email = $_POST[‘sl_email’];
    $sl_url = $_POST[‘sl_url’];
    $sl_hours = $_POST[‘sl_hours’];
    $sl_phone = $_POST[‘sl_phone’];
    $sl_fax = $_POST[‘sl_fax’];
    $sl_image = $_POST[‘sl_image’];
    $sl_private = $_POST[‘sl_private’];
    $sl_neat_title = $_POST[‘sl_neat_title’];
    $sl_linked_postid = $_POST[‘sl_linked_postid’];
    $sl_pages_url = $_POST[‘sl_pages_url’];
    $sl_pages_on = $_POST[‘sl_pages_on’];
    $sl_option_value = $_POST[‘sl_option_value’];
    $sl_lastupdated = $_POST[‘sl_lastupdated’];

    ?>
    <?php //Query

    //INSERT
    $query = ” INSERT INTO bqk_store_locator ( sl_id, sl_store, sl_address, sl_city, sl_country, sl_description, sl_email, sl_url, sl_hours, sl_phone, sl_fax, sl_image ) VALUES ( ‘$sl_id’, ‘$sl_store’, ‘$sl_address’, ‘$sl_city’, ‘$sl_country’, ‘$sl_description’, ‘$sl_email’, ‘$sl_url’, ‘$sl_hours’, ‘$sl_phone’, ‘$sl_fax’, ‘$sl_image’ ) “;
    $result = mysql_query($query);

    if( $result )
    {
    echo ‘Success’;
    }
    else
    {
    echo ‘Query Failed’;
    }

    ?>
    </div><!– #content –>
    </div><!– #primary –>
    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Your insert data script is running on GET requests, resulting in empty lines because there is nothing in $_POST. Place a line at the beginning of the PHP segment to exit if the request type is not POST.

    I’ve no idea for geocoding other than there is probably a third party API you could use to get the data by script.

Viewing 1 replies (of 1 total)
  • The topic ‘geocoding & not writing to DB empty lines’ is closed to new replies.