0

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

2
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by zerey02
0

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?

0

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

0

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']
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.