We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

jQuery - FreeForm - mySQL -- Need to pass data via ajax and modify entry in table

Development and Programming

a la mode's avatar
a la mode
168 posts
14 years ago
a la mode's avatar a la mode

I have a form that is being filled out for an unsubscribe function. In this I have the following jQuery for an ajax call:

// Mark the email as unsubscribed and add suggestions to DB
var email = $("#unsub_email").val();
var suggestions = $("#improvements").val();
var datastring = "email="+email+"&sugestions;="+suggestions;
$.ajax({
    type: "POST",
    url: "/php/unsub",
    data: datastring,
    success: function(data){
        // Do stuff here
    }
});

Then in my /php/unsub template, I am doing the following:

<?php
    $email = $_POST['email'];
    $suggestions = $_POST['suggestions'];

    $data = array('unsubscribed' => 'true', 'suggestions' => $suggestions);
    $sql = $this->EE->db->update_string('exp_freeform_entries', $data, "email = '$email'");
    $this->EE->db->query($sql);
?>

I have PHP allowed on INPUT.

If I hard code the variables, it will work. What am I doing wrong here?

Thanks,

       
a la mode's avatar
a la mode
168 posts
14 years ago
a la mode's avatar a la mode

WOW!!! I am an idiot… lol

If you look at the first block of cod, I have this:

// Mark the email as unsubscribed and add suggestions to DB
var email = $("#unsub_email").val();
var suggestions = $("#improvements").val();
var datastring = "email="+email+"&sugestions;="+suggestions;
$.ajax({
    type: "POST",
    url: "/php/unsub",
    data: datastring,
    success: function(data){
        // Do stuff here
    }
});

It’s kind of hard to get “suGGestions” from a string that only has “suGestions”!!!!

Spelling error kicked my tail yesterday. What a bone-head error.

Chalk it up to experience. Close this out please. :red:

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.