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

  • SEARCH
  • Home
  • 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 8723169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:34:03+00:00 2026-06-13T07:34:03+00:00

I am trying to use MySQL, Perl and JS to make a simple registration

  • 0

I am trying to use MySQL, Perl and JS to make a simple registration form for my website. The Perl script works fine when given parameters directly via cmdline or via the URL and the MySQL properly registers the user. The issue is with the JS; when I sent the data via a JSON post the Perl script receives the post and attempts to create a hash of the parameters given via the code:

%params = $cgh->Vars()

However, this doesn’t properly split the parameters and assign them to individual keys. Instead, the Perl script creates a hash that looks like this:

%params data

$VAR1 = 'POSTDATA';
$VAR2 = 'action=register&uname=d&pass=d&first=d&last=d&email=anemail@themailplace.com&phone=d';

I suspect that the JS needs to change how it is submitting the data and not the way the Perl script is accepting the data. In any case, here is the JS:

$(document).ready(function(){
    $("form#register-form").submit(function() { // register-form is submitted
        var username = $('#username').attr('value'); // get username
        var password = $('#password').attr('value'); // get password
        var repassword = $('#repassword').attr('value'); // get password
        var firstName = $('#firstName').attr('value'); // get password
        var lastName = $('#lastName').attr('value'); // get password
        var email = $('#email').attr('value'); // get password
        var phone = $('#phone').attr('value'); // get password

        if (username && password && repassword && firstName && lastName && email && phone) { // values are not empty
            $.ajax({
                type: "POST",
                url: "/cgi/login.pl", // URL of the Perl script
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                // send username and password as parameters to the Perl script
                data: "action=register" + "&uname=" + username + "&pass=" + password + "&first=" + firstName + "&last=" + lastName
                    + "&email=" + email + "&phone=" + phone,
                // script call was *not* successful
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    $('div#register-result').text("responseText: " + XMLHttpRequest.responseText
                        + ", textStatus: " + textStatus
                        + ", errorThrown: " + errorThrown);
                    $('div#register-result').addClass("error");
                }, // error 
                // script call was successful 
                // data contains the JSON values returned by the Perl script 
                success: function(data){
                    if (data.error) { // script returned error
                        $('div#register-result').text("data.error: " + data.error);
                        $('div#register-result').addClass("error");
                        } // if
                    else { // login was successful
                        $('form#register-form').hide();
//                        $('div#register-result').text("data.success: " + data.success + ", data.userid: " + data.userid);
//                        $('div#register-result').addClass("success");
                    } //else
                } // success
            }); // ajax
        } // if
        else {
            $('div#register-result').text("enter username and password");
            $('div#register-result').addClass("error");
        } // else
//    $('div#register-result').fadeIn();
    return false;
    });
});

Unless relevant to the issue, please ignore the fact that I do next to no checks on the info submitted by the form. Let me know if you require any more information. Thank you in advanced.

  • 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-06-13T07:34:04+00:00Added an answer on June 13, 2026 at 7:34 am

    You are not sending JSON to server so using contentType: "application/json; charset=utf-8", will over ride default 'application/x-www-form-urlencoded; charset=UTF-8'

    Using the default, server script deals with the key/value pairs as it would for any other form submission

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

Sidebar

Related Questions

I am trying to run simple perl dbi example script to connect to mysql
MySQL, Perl The following select works fine with no placeholders, but doesn't with placeholders.
I use MySQL server version 5.5.14 and now I am trying this simple SQL
I am trying to use perl to search and replace some outdated MySQL commands
I'm trying to use MySQL and ebeans for saving my tasks. When i apply
I am trying to use MySql Connector 6.2.2.0 for membership and role providers. The
I'm trying to use MySQL (5.5.22, Connector 6.5.4) with Entity Framework 4. I'm using
I'm trying to use a MySQL database to save player information, but whenever there
I'm trying to use the MySQL CASE statements to select products from a products
I am trying to use this MySQL query: SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1

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.