.Is there any way that i can get texts from a php form to supply it on another php form. and place it on the title attribute of my <a> tag.

for example:

<a href="" title=" //this is where i want to place the retrieved texts from my other php form." >

.Any help would be much appreciated.

this should work.

<?php
$var = "This is the title";
?>

<a href="http://www.example.com" title="<?=$var?>">

this should work.

<?php
$var = "This is the title";
?>

<a href="http://www.example.com" title="<?=$var?>">

.Thank you for your generous response sir, still there is a function that is missing..
.In the code that you have supplied <?php echo $var; ?> gets the string "This is the title" from the same php form right? what i want to do is to get the string from another php form and output it using <?php echo $var; ?>. should i use $_GET or $_POST function?

Hi,

It all depends how the value is being pass from the previous page to the current page. GET/POST.

<a href="http://www.example.com" title="<?=$_GET['var']?>">

or

<a href="http://www.example.com" title="<?=$_POST['var']?>">

.That's my prob.. i don't really know the proper way of passing the variables from the previous page to the current page.. could you please help me with the code.

From the first page, you can create a form like this..

<form action="secondpage.php" method="post">
<input type="text" name="firstname">
<input type="submit">

This form will pass the value in the textbox (firstname) via method POST (or you can change it to GET) to secondpage.php

On secondpage.php, this will print out the value of your submission

echo $_POST['firstname'] //firstname is the name of the textbox created in the form
//If you use GET, change to $_GET['firstname']

From the first page, you can create a form like this..

<form action="secondpage.php" method="post">
<input type="text" name="firstname">
<input type="submit">

This form will pass the value in the textbox (firstname) via method POST (or you can change it to GET) to secondpage.php

On secondpage.php, this will print out the value of your submission

echo $_POST['firstname'] //firstname is the name of the textbox created in the form
//If you use GET, change to $_GET['firstname']

.I already did this before but what i want is to get a variable from my first page that has already a value in it and send it to secondpage.php.

it's like this:

I have a page named firstpage.php where it contains declared variables such as $name = "MyName" and I have a secondpage.php, what i want to do is when i load secondpage.php a certain code will automatically get the variable $name from firstpage.php and then echo it out on secondpage.php..

That's it.

you're suppose to use your own domain.

put in your secondpage.php

<?=$_GET['name']?>

and access it via

http://your-domain-or-localhost/secondpage.php?name=MyName

oh i see, sir this code is quite useful, i think. but let's not forget the title of this thread. by using the method that you gave me I am not able to call the strings from firstpage.php and output it on the <a> tag. and set it as the title attribute.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.