Hi, I have login.html , login,js ang login.pl.
I want to integrate basic login page in Django with perl back-end from where Am reading my DB. I was trying to integrate it from last day but come out with empty .There might be some settings in setting.py. Below is my code -------------- login.html -------------- <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jquery-1.7.2.min.js"></script> <script type="text/javascript" src="login.js"></script> <style type="text/css"> #loginContent { width: 350px; margin: 100px auto; } button[type] { margin: 0.5em 0; } label {font-weight:bold;} fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;} legend {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;} fieldset, #IE8#HACK {padding-top:1.4em;} legend, #IE8#HACK {margin-top:0;margin-bottom:0;} input[type=text], input[type=password], input.text, input.title, textarea {background-color:#fff;border:1px solid #bbb;} input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus {border-color:#666;} select {background-color:#fff;border-width:1px;border-style:solid;} input[type=text], input[type=password], input.text, input.title, textarea, select {margin:0.5em 0;} input.text, input.title {width:300px;padding:5px;} input.title {font-size:1.5em;} textarea {width:390px;height:250px;padding:5px;} form.inline {line-height:3;} form.inline p {margin-bottom:0;} .error, .alert, .notice, .success, .info {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;} .error, .alert {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;} .notice {background:#fff6bf;color:#514721;border-color:#ffd324;} .success {background:#e6efc2;color:#264409;border-color:#c6d880;} .info {background:#d5edf8;color:#205791;border-color:#92cae4;} .error a, .alert a {color:#8a1f11;} .notice a {color:#514721;} .success a {color:#264409;} .info a {color:#205791;} </style> </head> <body> <div id="loginContent" class="container"> <div id="loginResult" style="display:none;"> </div> <form id="loginForm" name="loginForm" method="post" action=""> <fieldset> <legend>Enter information</legend> <p> <label for="username">Username</label><input type="text" id="username" name="username" class="text" size="20" /> </p> <p> <label for="password">Password</label><input type="password" id="password" name="password" class="text" size="20" /> </p> <p> <button type="submit" class="button positive"><img alt="ok" />Login</button> </p> </fieldset> </form> </div> </body> </html> --------------------- login.js --------------------- $(document).ready(function(){ $("form#loginForm").submit(function() { // loginForm is submitted var username = $('#username').attr('value'); // get username var password = $('#password').attr('value'); // get password if (username && password) { // values are not empty $.ajax({ type: "GET", url: "http://localhost:8080/cgi-bin/login.pl", // URL of the Perl script contentType: "application/json; charset=utf-8", dataType: "json", data: "username=" + username + "&password=" + password, error: function(XMLHttpRequest, textStatus, errorThrown) { $('div#loginResult').text("responseText: " + XMLHttpRequest.responseText + ", textStatus: " + textStatus + ", errorThrown: " + errorThrown); $('div#loginResult').addClass("error"); }, // error success: function(data){ if (data.error) { // script returned error $('div#loginResult').text("data.error: " + data.error); $('div#loginResult').addClass("error"); } // if else { // login was successful $('form#loginForm').hide(); $('div#loginResult').text("data.success: " + data.success + ", data.userid: " + data.userid); $('div#loginResult').addClass("success"); } //else } // success }); // ajax } // if else { $('div#loginResult').text("enter username and password"); $('div#loginResult').addClass("error"); } // else $('div#loginResult').fadeIn(); return false; }); }); ------------------ login.pl ------------------ #!/usr/bin/perl -T use CGI; use DBI; use strict; use warnings; use netsharkusr; my $cgi = CGI->new; my $username = $cgi->param("username"); my $password = $cgi->param("password"); my $tempuser = new netsharkusr(); if($tempuser->readbyusername($username) eq 1) { if($tempuser->{username} eq $username) { print "success \n"; #exit; } } #$password = "123go"; my $userid; my $tempuser2 = new netsharkusr(); if($tempuser2->readbypassword($password)) { if($tempuser2->{password} eq $password) { print "sccess \n"; $userid = $tempuser2->{userID}; } } # check the username and password in the database # create a JSON string according to the database result my $json = ($userid) ? qq{{"success" : "login is successful", "userid" : $userid}} : qq{{"error" : "username or password is wrong"}}; # return JSON string print $cgi->header(-type => "application/json", -charset => "utf-8"); print $json; How can I do this ......? Please Help Thank You Pervez -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/R6Q12CRToVMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.