Note that there are some explanatory texts on larger screens.

plurals
  1. POEmpty Array sent by PHP contact form - pretty sure it's HTACCESS's fault
    primarykey
    data
    text
    <p>Here's the scenario: I have a contact form with few checkboxes:</p> <pre><code>&lt;input type="text" name="cola[]" value="coke" /&gt; &lt;input type="text" name="cola[]" value="pepsi" /&gt; &lt;input type="text" name="cola[]" value="rc" /&gt; </code></pre> <p>Using jQuery's serialize, I have the data string sent to my <code>mailer.php</code> like so:</p> <pre><code>$.ajax({ type: "POST", url: "http://mydomain.com/mailer", data: dataString, success: function() {//some function} }); </code></pre> <p>Notice that I have had to omit the <code>.php</code> extension from the URL, due to a htaccess rewrite rule. If all 3 checkboxes are checked, the data string looks like: <code>&amp;cola=coke&amp;cola=pepsi&amp;cola=rc</code>. I verified this using <code>console.log</code>.</p> <p><code>mailer.php</code> looks like this:</p> <pre><code>$cola = $_POST["cola"]; // other code $message = "&lt;p&gt;" . $cola . "&lt;/p&gt;"; // code to mail it out </code></pre> <p>However, upon successful mailing, the email body text just says "Array", instead of "cola, pepsi, rc".</p> <p>I have a feeling it may be something to do with my rewrite conditions in my htaccess, which looks like this:</p> <pre><code>RewriteEngine On # Unless directory, remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L] # Redirect external .php requests to extensionless url RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/ RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L] # Resolve .php file for extensionless php urls RewriteRule ^([^/.]+)$ $1.php [L] </code></pre> <p>My rewrite conditions are to remove any trailing <code>/</code> from the URL and wipe out the .php file extensions so that urls look like: <code>domain.com/pretty</code></p> <p>Can anybody help me diagnose why I'm getting the message "Array" instead of the array contents? Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload