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,
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:
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.