Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 627921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:34:50+00:00 2026-05-13T19:34:50+00:00

Here is what I have going on in my AJAX: $(‘#submit-button’).click(function(){ var twit =

  • 0

Here is what I have going on in my AJAX:

$('#submit-button').click(function(){
    var twit = $('input#twittername').val();
    var email = $('input#email').val();
    if((email == "" || email == "you@address.com") && (twit == "" || twit == "@twittername")){
        $('p#empty-error').fadeIn();

    return false;
    }

    var datastring = 'email=' + email + '&twit=' + twit;

    if(email != "you@address.com"){
        $.ajax({
            type: 'POST',
            url: '/path/to/script1.php',
            data: datastring,
            success: function(){
                $('#signup').fadeOut('slow',function(){
                    $('#email-response').fadeIn('slow');
                });
            }
        });

        return false;
    }

    if(twit != "@twittername"){     
        $.ajax({
            type: 'POST',
            url: '/path/to/script2.php',
            data: datastring,
            success: function(){
                $('#signup').fadeOut('slow', function(){
                    $('#email-response').fadeIn('slow');
                });
            }       
        });
    }

    return false;       
});

AJAX is returning the success function. And I can navigate directly to /path/to/script2.php, and it will add an empty record to my database. But for some reason, the PHP is not actually receiving and inserting the AJAX variable.

This was working before, and I’m unsure at what point it stopped. It’s just a bit strange that it is two scripts that were both working, and now neither are.

Script one was written by me, and it inserts a blank record if I navigate straight to it:

<?php

$dbhost = 'host';
$dbuser = 'user';
$dbpass = 'pw';

$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) {
    die('Could not connect: ' . mysql_error());
}

$dbname = 'databasename';
mysql_select_db($dbname, $con);

$sql = "INSERT IGNORE INTO databasename (column) VALUES ('$_POST['twit']')";

if (!mysql_query($sql)){
    die('Error: ' . mysql_error());
}

echo 'record added successfully';

mysql_close($con);

Script two is modified from MailChimp, and this does nothing if I navigate straight to it, which is expected:

function storeAddress(){

    // Validation
    if(!$_POST['email']){ return "No email address provided"; } 

    if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $_POST['email'])) {
        return "Email address is invalid"; 
    }

    require_once('MCAPI.class.php');
    // grab an API Key from http://admin.mailchimp.com/account/api/
    $api = new MCAPI('66a7f17d87e96e439f7a2837e2963180-us1');

    // grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
    // Click the "settings" link for the list - the Unique Id is at the bottom of that page. 
    $list_id = "b1ebe7c0ba";

    if($api->listSubscribe($list_id, $_POST['email'], '') === true) {
        // It worked!   
        return 'Success! Check your email to confirm sign up.';
    }else{
        // An error ocurred, return error message   
        return 'Error: ' . $api->errorMessage;
    }

}

// If being called via ajax, autorun the function
if($_POST['email']){ echo storeAddress(); }
?>

Any ideas where I’m going wrong?

Also: I can successfully alert the datastring, if that’s any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:34:50+00:00Added an answer on May 13, 2026 at 7:34 pm

    Needed to delete the top “return false.” A fun way to spend 4 hours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.