Jump to content

echo <?p $_GET["nameoftextarea"]; ?> Not Working


Avocado

Recommended Posts

My html form:

 

<body>

<form>

<p>Enter a sentence:</p>

<textarea rows="3" cols="20" name="nameoftextarea">

</textarea>

<input type="button" value="Send Sentence" onclick="getServerText()">

</form>

<div id="myPageElement">

Sentence will show here

</div>

</body>

 

getServerText is the function for sending the XMLHTTPRequest object.

 

<head>

<script Language="JavaScript">

 

function getXMLHTTPRequest() {

try {

req = new XMLHttpRequest();

} catch(err1) {

  try {

  req = new ActiveXObject("Msxml2.XMLHTTP");

  } catch (err2) {

    try {

    req = new ActiveXObject("Microsoft.XMLHTTP");

    } catch (err3) {

      req = false;

    }

  }

}

return req;

}

 

var http = getXMLHTTPRequest();

 

function getServerText() {

  var myurl = 'phppage.php';

  myRand = parseInt(Math.random()*999999999999999);

  var modurl = myurl+"?rand="+myRand; 

  http.open("GET", modurl, true);

  http.onreadystatechange = useHttpResponse;

  http.send(null);

}

 

function useHttpResponse() {

  if (http.readyState == 4) {

    if(http.status == 200) {

      var mytext = http.responseText;

      document.getElementById('myPageElement').innerHTML = mytext;

    }

  } else {

  document. getElementById('myPageElement').innerHTML = "";

  }

}

 

</script>

</head>

 

The the $_GET["nameoftextarea"] on the php page doesn't display in <div> but the "Hi" does

 

 

<html>

<body>

Hi <?php echo $_GET["nameoftextarea"];?>

</body>

</html>

 

 

I just started php and I don't see where the error is, thanks.

Link to comment
https://forums.phpfreaks.com/topic/193878-echo-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.