Jump to content

Recommended Posts

I'm really stumped here.

 

On index.php, there is a text input and a button.

When you click the button, test.php is loaded onto index.php

 

How would i pass along what the user wrote in the text input without refreshing the page?

 

Thanks!

 

index.php

<script type="text/javascript">
function load_new()
{
document.getElementById('AfterWallPost').innerHTML = "<iframe frameborder='0' src='http://mysite/test.php'></iframe>";
}

</script>
<div id="AfterWallPost">
<form method="POST">
<input type="text" name="wall">
<input type="submit" value="Post Comment!" onclick="load_new()">
</div>

 

test.php

<?php
echo "Cool Beans!";

$wall = "This was the Wall Post";
echo "<br> $wall ";
?>

Link to comment
https://forums.phpfreaks.com/topic/110350-passing-information-on-same-page/
Share on other sites

ohhhh alright.

 

So could i do this is javascript or ajax???

 

For you facebook users out there, to give you an example, its like the Facebook Profile wall. It sends your post to the server, and then displays what you wrote, without refreshing the page... and facebook is a PHP/MySQL site, so i guess they use js or ajax..

 

Thanks!

an example of this would be:

 

index.php


<form action = 'test.php' method='post'>
   <input type="text" name="wall">
   <input type="submit" value="Post Comment!">
</form>

test.php

<?php

if ($_POST['wall']) {
   echo $_POST['wall']; 
}
?>

 

Yes, you can use ajax to make a request and update an element on the page without refreshing the whole page.

oh i know how to handle php forms.

 

Its just i don't want to reload the page.

 

Yes, you can use ajax to make a request and update an element on the page without refreshing the whole page.

 

oh ok....

i found this:

http://www.boutell.com/newfaq/creating/ajaxfetch.html

 

but it doesn't make any sense... h/o i'll try some more...

 

 

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.