ok i need a LOT of help here. what i have is a html form (with a tiny bit of php in it) and a php file that takes the variables in the form and does stuff with them
heres the form:
<form method="post" action="dostuff.php">
name:<br>
<input type="text" name="name"><br>
email:<br>
<input type="text" name="email"><br>
[url]http://[/url]<br>
<input type="text" name="url"><br>
location:<br>
<input type="text" name="country"><br>
<input type="submit" value="submit">
<textarea name="layout" rows="1"><?php include ("indivtxt.txt"); ?></textarea>
</form>
ok as you can see there are 5 variables ($name, $email, $url, $country, $layout) and in a textarea the file "indivtxt.txt" has been included. within the file "indivtxt.txt" there will be 4 things that a user has put their using a different file ([[name]] [[email]] [[url]] [[location]])
heres the php:
<?php
$keyword_name = "[[name]]" ;
$replacement_name = "$name";
preg_replace("/\b$keyword_name\b/i", "$replacement_name", $layout);
$keyword_email = "[[email]]" ;
$replacement_email = "$email";
preg_replace("/\b$keyword_email\b/i", "$replacement_email", $layout);
$keyword_url = "[[url]]" ;
$replacement_url = "$url";
preg_replace("/\b$keyword_url\b/i", "$replacement_url", $layout);
$keyword_location = "[[location]]" ;
$replacement_location = "$country";
preg_replace("/\b$keyword_location\b/i", "$replacement_location", $layout);
$filename = 'dog.txt';
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
if (!fwrite($handle, $layout)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success";
fclose($handle);
} else {
print "The file $filename is not writable";
}
?>
now here what i want to do. once a user has submitted the form i want the php to recognise that there is [[name]] [[email]] etc. in the variable $layout and replace them with the variables from the form ($name, $email etc) then write the variable $layout to the file "dog.txt". but, the preg_replace function isnt doing anything and just comes out with a string of text in the files "dog.txt" that says ([[name]] [[email]] [[url]] [[location]]) what have i done wrong?