Jump to content

+ escape(encodeURI( document.getElementById("name").value )) +


farkewie

Recommended Posts

Hi i was told this is the place to post aout ajax so i am re posting after looking at the sugested walkthrough.

 

i am using "Yahoo! UI Library" i am trying to post some simple details from 2 textfields to a php page called post.php

 

it can access post .php becase it is displaying the info sent back. the only thing i cant get to work is sending the contents of the text fields through.

 

if i hard code the info it all works fine i have tried every thing i can find below is my latest code

 

INDEX.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="fuckme">
<script src="js/yahoo.js"></script>
<script src="js/event.js"></script>
<script src="js/connection.js"></script>
<title>AJAX TESTING </title>
</head>

<body>
<form name="form1" method="post" action="" id="form1">
<table width="204">
<tr><td>name</td><td>pass</td>
</tr>
   <tr>
     <td><label>
       <input type="text" name="name" id="name">
     </label></td>
     <td><label>
       <input type="text" name="pass" id="pass">
     </label></td>
   </tr>
 </table>
 <label>
<input type="button" name="button" id="button" value="Submit" onClick="makeRequest();" >
 </label>
</form>


<div id="container"></div>

<script>
var div = document.getElementById('container');

var handleSuccess = function(o){
YAHOO.log("The success handler was called.  tId: " + o.tId + ".", "info", "example");
if(o.responseText !== undefined){
	div.innerHTML +=  o.responseText;

}
};

var handleFailure = function(o){
	YAHOO.log("The failure handler was called.  tId: " + o.tId + ".", "info", "example");

if(o.responseText !== undefined){
	div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
	div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
	div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
}
};

var callback =
{
 success:handleSuccess,
 failure:handleFailure,
 argument:['foo','bar']
};
//var name = document.form1('name').value;
//var pass = document.form1('pass').value;
//var pass = document.getElementById('pass').value;
//var name = document.getElementById('name').value;
//YAHOO.util.Connect.setForm(form1); 
var sUrl = "post.php";
var postData = "name=" + escape(encodeURI( document.getElementById("name").value )) + "&pass=" + escape(encodeURI( document.getElementById("pass").value )) + "&hello=HI";

function makeRequest(){

var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);

YAHOO.log("Initiating request; tId: " + request.tId + ".", "info", "example");

}

YAHOO.log("As you interact with this example, relevant steps in the process will be logged here.", "info", "example");
</script>





</body>
</html>

 

POST.php

 

<?php

$USER = "tyron";
$PASS = "test";

if ((($_POST['name']) == $USER) && (($_POST['pass']) == $PASS)) {
echo <<<EOT
You are now logged in !!!!
EOT;
}
else {
echo <<<EOT
FUCK OFF!!!

EOT;
print "<pre>";
print_r($_POST);
}

?>

 

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.