Shortcode Exec PHP
embedding form handlers - extra carriage returns (3 posts)

  1. sandbergs
    Posted 5 years ago #

    I am using a form handler in my php code and embedding the shortcode in a wordpress page. I am getting carriage returns entered into the page above the form - the number of carriage returns seems to correspond with the number of lines I have in the form handler. Any way to correct this?

    My code:
    if (isset($_POST['wc_firstname']))
    $wc_firstname = $_POST['wc_firstname'];
    if (isset($_POST['wc_lastname']))
    $wc_lastname = $_POST['wc_lastname'];
    if (isset($_POST['wc_address1']))
    $wc_address1 = $_POST['wc_address1'];
    if (isset($_POST['wc_address2']))
    $wc_address2 = $_POST['wc_address2'];
    if (isset($_POST['wc_city']))
    $wc_city = $_POST['wc_city'];
    if (isset($_POST['wc_state']))
    $wc_state = $_POST['wc_state'];
    if (isset($_POST['wc_zip']))
    $wc_zip = $_POST['wc_zip'];
    if (isset($_POST['wc_email']))
    $wc_email = $_POST['wc_email'];
    if (isset($_POST['wc_attendees']))
    $wc_attendees = $_POST['wc_attendees'];
    if (isset($_POST['wc_email']))
    save_wcinfo($wc_firstname, $wc_lastname, $wc_address1, $wc_address2, $wc_city, $wc_state, $wc_zip, $wc_email, $wc_attendees);
    <form method="post" action=""><table><tr>
    <td><label>First Name</label></td>
    <td colspan="2"><input type="text" name="wc_firstname" style="width:200px;"></td></tr>
    <td><label>Last Name</label></td>
    <td colspan="2"><input type="text" name="wc_lastname" style="width:200px;"></td></tr>
    <td><label>Address 1</label></td>
    <td colspan="2"><input type="text" name="wc_address1" style="width:200px;"></td></tr>
    <td><label>Address 2</label></td>
    <td colspan="2"><input type="text" name="wc_address2" style="width:200px;"></td></tr>
    <td colspan="2"><input type="text" name="wc_city" style="width:200px;"></td></tr>
    <td colspan="2"><input type="text" name="wc_state" style="width:200px;"></td></tr>
    <td colspan="2"><input type="text" name="wc_zip" style="width:200px;"></td></tr>
    <td colspan="2"><input type="text" name="wc_email" style="width:200px;"></td></tr>
    <td><label># Attendees</label></td>
    <td colspan="2"><input type="text" name="wc_attendees" style="width:200px;"></td></tr>
    <input type="submit" value="Submit">

  2. M66B
    Plugin Contributor

    Posted 5 years ago #

    I am not seeing this behavior. I assumed all the above code was in the PHP code field of the Shortcode Exec PHP plugin. I added <? at the end to make it working, maybe that is your problem.

  3. sandbergs
    Posted 5 years ago #

    hmm, well i have solved the problem for now by removing all carriage returns in my php code.. as follows.

    if (isset($_POST['wc_firstname'])) { $wc_firstname = $_POST['wc_firstname']; } if (isset($_POST['wc_lastname'])) { $wc_lastname = $_POST['wc_lastname']; } if (isset($_POST['wc_address1'])) { $wc_address1 = $_POST['wc_address1']; } if (isset($_POST['wc_address2'])) { $wc_address2 = $_POST['wc_address2']; } if (isset($_POST['wc_city'])) { $wc_city = $_POST['wc_city']; } if (isset($_POST['wc_state'])) { $wc_state = $_POST['wc_state']; } if (isset($_POST['wc_zip'])) { $wc_zip = $_POST['wc_zip']; } if (isset($_POST['wc_email'])) { $wc_email = $_POST['wc_email']; } if (isset($_POST['wc_attendees'])) { $wc_attendees = $_POST['wc_attendees']; } if (isset($_POST['wc_email'])) { save_info($wc_firstname, $wc_lastname, $wc_address1, $wc_address2, $wc_city, $wc_state, $wc_zip, $wc_email, $wc_attendees); } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic