CaTzArOv CaTzArOv - 1 year ago 71
HTML Question

How to add href link with multiple php values?

I have little problem with php web form for add link.

I want the form to record the values in:

<a href="$_POST['field1']" target="_blank" rel="nofollow" title=".$_POST['field3']">.$_POST['field2']</a>

But I don't know how to do it to work correctly.

My code is...
HTML form code:

<form action="myprocessingscript.php" method="POST">
<p>Уеб Сайт: </p><input name="field1" type="text" placeholder="" /><br />
<p>Ключова дума: </p><input name="field2" type="text" placeholder="Моят Личен Блог" /><br />
<p>Описание: </p><input name="field3" type="text" placeholder="Личен Блог за интересни неща" /><br />
<br /><input type="submit" name="submit" value="Добави сайта">

myprocessingscript.php code is:

if(isset($_POST['field1']) && isset($_POST['field2']) && isset($_POST['field3'])) {
$data = '<a href='.$_POST["field1"]' target='_blank' rel='nofollow' title='.$_POST["field3"]'>.$_POST["field2"]</a>' . "\n";
$ret = file_put_contents('mydata.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
else {
echo "$ret bytes written to file";
else {
die('no post data to process');

and my code for show form records is:

$myfile = fopen("mydata.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
echo fgets($myfile);

I want to use this form on my website so that visitors can add their link to them. I don't understand how to use $_POST['field1'] in HTML row.

Thanks for your time and attention.

Answer Source
<a href="<?php echo $_POST['field1']?>" target="_blank" rel="nofollow" title="<?php echo $_POST['field3'] ?>"><?php echo $_POST['field2'] ?></a>



echo '<a href="' . $_POST['field1'] . '" target="_blank" rel="nofollow" 
title="' . $_POST['field3'] . '"><' . $_POST['field2'] . '</a>':

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download