0
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asiahome Trading Corporation (Server)</title>
<script language="javascript" type="text/javascript">

function validate(){
var user = document.getElementById('username')
var pass = document.getElementById('password')

user.style.backgroundColor = (user.value.length == 0) ? "red" : "";
pass.style.backgroundColor = (pass.value.length == 0) ? "red" : "";

if(user.value.length == 0 || pass.value.length == 0){
        if (user.value.length == 0){
            user.focus();
            return false;
            }
        else if (pass.value.length == 0){
            pass.focus();
            return false;
            }
    }
else if (user.value.length != 0 || pass.value.length != 0){
    document.forms["frmLogin"].submit();
    }
}

</script>
</head>

<body>

<form id="frmLogin" method="post" action="sample.php">
<table width="254" border="0">
  <tr>
    <td width="100"></td>
    <td width="144"><input type="text" name="username" id="username" /><input type="password" name="password" id="password"/></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="button" value="Login" onclick="validate()"/><input type="reset" value="Cancel" /></td>
  </tr>
</table>
</form>
</body>
</html>

this one is working, all i want happen is
how can i receive and post the value of username and password to another page(sample.php)
friendsssss plssss!!!!!!!!!!!!!!!!!!!!

Edited by pyTony: fixed formatting

2
Contributors
7
Replies
9
Views
6 Years
Discussion Span
Last Post by Amr87
0

This is Technically a PHP Question
The Answer is that you can access the value of username and password in sample.php using the global variable $_POST (because the form action is POST ) if it is GET then u use $_GET and and u need to pass to the $_POST the index (name) of the field that you want to capture its value as following

$username = $_POST;
$password = $_POST;

REMEMBER THAT THESE VALUES ARE ONLY ACCESSIBLE WHEN THE FORM IS SUBMITTED
If you tried to grab it without submitting the form you will get PHP ERROR

0

Amr87, actually i know how to do that in php. want i want is in javascript way.
how can i do post the value of my username and password using javascript.?

0

what i want to happen is to send all value from one form and send it and post it to another page.

0

ok, you said you want to do POST operation for data from page to another and this is always handled by server side application like PHP

Edited by Amr87: n/a

0

so javascript cant do that??? hmmm how about if am using cookie??? how can i code that?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.