View Full Version : Php Post?

02-03-2008, 01:15 PM
What I am trying to do is take text from one page, and place it on another page. The text MUST only be between <name="body"> and </name>.

This is the page with the text on;


Hello and welcome to the website.

Then, I have another page, which the text from index.htm is placed onto;


$text = $_POST['text'];
The text you wanted was;
<?php echo $name ?>

Ok, firstly, is there any reason why that wouldn't work?

Now, what i really came here for;

I have 3 pages, index.htm, services.htm and help.htm. Each of these will be set up the same as index.htm, with some text in <name> tags.

When a user click a link, they must go to show.php (the page where the text is placed onto). I want to be able to identify the page from which they came from, and place the text from that page on this show.php.

If I haven't been very clear, please ask as I rally need this help.


02-03-2008, 01:44 PM
Well, from what I understand you cannot make something that will do that because <name> isn't a tag. you would need to do this:

<p name="text">
Hello and welcome to the website.

02-03-2008, 01:48 PM
OK thanks Nile =)

02-03-2008, 02:00 PM
Can you +thanks me please? By clicking on the http://www.dynamicdrive.com/forums/images/buttons/post_thanks.gif
under my post?

02-04-2008, 08:40 AM
Don't think you should ask people to thank you... it's something the poster does at their own will.

02-04-2008, 09:32 AM
Hi MrRSMan,

Have a look at the following code

File 1:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title> </title>
<style type="text/css">

<script type="text/javascript">
function redirect(){
location.href = "get.php?text=" + document.body.getElementsByTagName('div')[0].getAttribute('text');

function getTheValue(form){
var txt = document.createElement('input');
txt.type = 'text';
txt.value = document.body.getElementsByTagName('div')[0].getAttribute('text');
txt.name = 'text';
txt.style.display = 'none';

return true;
<div text="your_text_value_goes_here"><a href="#" onclick="javascript: redirect();">Click To Load - GET METHOD</a> <div>
<br />
<form name="form1" action="get.php" method="post" onsubmit="return getTheValue(this);">
<input type="submit" name="submit" value="Submit POST" />

File 2:

print "The value you've transferred from the HTML page through GET method is " . $_GET['text'];
print "The value you've transferred from the HTML page through POST method is " .$_POST['text'];

1. Put both files inside your web publish folder.

2. Make sure that you name the PHP file as 'get.php'

3. Browse the HTML file and click either the hyper link or the button.

4. Hyper link will demonstrates a GET HTTP method in PHP

5. Button will demonstrates a POST HTTP method in PHP

Hope this help and please let me know if there is any confusion in the provided code.