Page 1 of 1

echo out a link

Posted: Thu Apr 15, 2010 2:18 pm
by Goofan
Is it possible to echo out ahref´s?
if so then what am i doing wrong?

Code: Select all

<?php
session_start();
$user = $_POST['username'];
echo "need to enter a value into the textbox";
$_session['User'];
print "<a href='New/index.php'>Continue</a><br>";
?>
<html>
<head>
<title>localhost/index</title>
</head>
<body>

<INPUT TYPE = "text" Name = "username" value = "">
</body>
</html>
it echo out this:
Continue
"; ?> //and the textbox

Re: Hey

Posted: Thu Apr 15, 2010 2:41 pm
by mikosiko
try changing your first line

<?php for <? and test

Re: Hey

Posted: Thu Apr 15, 2010 2:55 pm
by Goofan
still same :(

Re: echo out a link

Posted: Thu Apr 15, 2010 3:34 pm
by mikosiko
your code works for me without changes.... I can reproduce your error using short tags (in my case), hence my suggestion.... also.. this lkine caught my attention :?:

Code: Select all

$_session['User'];

Re: echo out a link

Posted: Thu Apr 15, 2010 3:55 pm
by Goofan
yea typo =) not supposed to be there :o


Although u say it work for you?
hmm maybe something wrong with my systems... :(

Re: Hey

Posted: Thu Apr 15, 2010 6:58 pm
by minorDemocritus
mikosiko wrote:try changing your first line

<?php for <? and test
A good habit. Don't use <?, use <?php. ALWAYS.

Goofan:
The reason it's messing up is that you're echoing out "need to enter a value into the textbox" and the link code BEFORE the <html> start tag. So try something like this, instead:

Code: Select all

<?php
session_start();
$display = '';
$user = $_POST['username'];
$display .= "need to enter a value into the textbox";
$_session['User'];
$display .= "<a href='New/index.php'>Continue</a><br>";
?>
<html>
<head>
<title>localhost/index</title>
</head>
<body>
<?php echo $display; ?>

<INPUT TYPE = "text" Name = "username" value = "">
</body>
</html>

Re: echo out a link

Posted: Fri Apr 16, 2010 7:26 am
by Goofan
Copy pasted ure code that u posted... still dont work same result... :(

Re: echo out a link

Posted: Fri Apr 16, 2010 7:40 am
by Goofan
Now it works! It were a bug =) dont really know how/what or why but it works =)

Re: echo out a link

Posted: Fri Apr 16, 2010 10:55 am
by minorDemocritus
Goofan wrote:Now it works! It were a bug =) dont really know how/what or why but it works =)
Maybe your browser was caching the page? Oh well.

Re: echo out a link

Posted: Fri Apr 16, 2010 4:29 pm
by Goofan
nah think it were with my Wampserver... i had to reinstall it =)