PDA

View Full Version : Transfer of variables to PHP page



gsashwin
18 Nov 2010, 12:55 AM
I am trying to transfer the variables of the form (username & password )in the html page to the process.php page which are both given below. However I am not able to read those values from the process.php page. Can anyone please let me know what is going wrong here? Thanks in advance and appreciate your help. The code for HTML page is below.

HTML Page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript" type="text/javascript">
function xor_str()
{
var username_val = document.forms['the_form'].elements["username"].value;
var password_val = document.forms['the_form'].elements["password"].value;
var xor_key='1234';
var username_res="";
var password_res=""
for(i=0;i<username_val.length;++i)
{
username_res+=String.fromCharCode(xor_key^username_val.charCodeAt(i));
}
for(i=0;i<password_val.length;++i)
{
password_res+=String.fromCharCode(xor_key^password_val.charCodeAt(i));
}
// XOR is done

//shifting the username_res to the left by 1 bit
//username_res = username_res << 1;
//shifting the password_res to the left by 1 bit
//password_res = password_res << 1;

//setting the xor'ed and shifted value for submission
document.forms['the_form'].elements["username"].value = username_res;
document.forms['the_form'].elements["password"].value = password_res;
//alert("UserName: " + username_res);
//alert("Password: "+ password_res);
the_form.submit(); // is this step right?


}
</script>
</head>

<body>
<form name="the_form" action="process.php" method="post">
<table>
<tr><td colspan="3">Username:<input type="text" name="username"></td></tr>
<tr><td>Password: <input type="text" name="password"></td><td colspan="2"><input type="button" onClick="xor_str()" value="Submit"></td></tr>
</table>
</form>
</body>s

</html>






Process.php page


<html><body>
<?php
$username = $_POST['username'];
$password = $_POST['password'];

echo "You ordered ". $username . " " . $password . ".<br />";
echo "Thank you ";

?>
</body></html>