LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-20-2010, 04:50 PM   #1
Neethusha
LQ Newbie
 
Registered: Feb 2010
Posts: 16

Rep: Reputation: 0
POST method and PHP - Login Verification


I wrote a code for login verification..I got output with GET. But i need output with POST since it is more secure.pls let me know if there is any error in my code.


javascript code:

var xml;
function verifyusernamepasswd(pass)
{
//pass is password that will be passed as parameter
xml=new XMLHttpRequest();
var url="http://localhost/loginvalidate.php";
var para="q="+username+"&p="+pass;//username is global
xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xml.setRequestHeader("Content-length", para.length);
xml.setRequestHeader("Connection", "close");
xml.open("POST",url,true);
xml.onreadystatechange=statechanged1;
xml.send(para);

}

function statechanged1()
{
if(xml.readyState==4)
alert(xml.responseText);

}



php code:

<?php
$username=$_POST["q"];
$password=$_POST["p"];
$con=mysql_connect("localhost","root","blaze");
if(!$con)
{
die('Could not connect: '.mysql.error());
}
mysql_select_db("BLAZE",$con) or die("No such Db");
$result=mysql_query("SELECT Passwword FROM USERTABLE WHERE Userhandle='$username'");
if($result==null)
echo "false";

else if($result!=null)
{
$row=mysql_fetch_array($result);
if((strcmp($row['Passwword'],$password)==0))
echo "true";
else
echo "false";
}

?>


the verification does not return anything, cos my alert is not displayed at all...pls tell me whats wrong....
 
Old 03-20-2010, 05:44 PM   #2
mattca
Member
 
Registered: Jan 2009
Distribution: Slackware 14.1
Posts: 333

Rep: Reputation: 56
Hey, would you mind editing your post, formatting your code properly, and then putting it between CODE tags? It's hard to read as it is, and I kind of have a personal rule that I won't work with poorly-formatted code if I don't have to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php post method paypal submit UMG:Chicken_Soüp Programming 2 02-03-2008 03:19 AM
PHP GET/POST Setup link for email verification ALInux Programming 2 07-25-2006 02:22 AM
Problem with method Post & Get (PHP) manhcuong Linux - Software 4 03-01-2006 07:16 AM
getting value of a form using post method in php mohtasham1983 Programming 5 01-11-2006 09:02 PM
PHP Post and GET method dai Programming 4 02-26-2003 09:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration