View Full Version : displaying a url as an echo

03-26-2007, 04:32 AM
I am making a page generator, and I am making a page where you can view your own page, so far I have this...
$page2 = $_POST['pageid'];
$page = "{$page2}.html";

echo ' <a href="http://www.tackypenguin.com/freepages/$page">Continue</a> ';
?> when i fill out the form I made, it says continue but it goes to http://www.tackypenguin.com/freepages/$page exactly like that. so say I put in ryan in the form it generates http://www.tackypenguin.com/freepages/$page. It is supposed to generate http://www.tackypenguin.com/freepages/ryan.html

03-26-2007, 04:42 AM
PHP won't parse variables in your string unless you use double quotes. You can use concatenation too:

echo '<a href="http://www.tackypenguin.com/freepages/' . $_POST['pageid'] . '.html">Continue</a> ';
Also, it's a good idea to remove any invalid characters from user input before you use it. ereg_replace() (http://www.php.net/manual/en/function.ereg-replace.php) preg_replace() (http://www.php.net/manual/en/function.preg-replace.php)

03-26-2007, 04:59 AM
okay thank you. :D