echo out a link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

echo out a link

Post 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
Last edited by Goofan on Thu Apr 15, 2010 2:55 pm, edited 1 time in total.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Hey

Post by mikosiko »

try changing your first line

<?php for <? and test
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Hey

Post by Goofan »

still same :(
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: echo out a link

Post 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'];
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: echo out a link

Post by Goofan »

yea typo =) not supposed to be there :o


Although u say it work for you?
hmm maybe something wrong with my systems... :(
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: Hey

Post 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>
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: echo out a link

Post by Goofan »

Copy pasted ure code that u posted... still dont work same result... :(
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: echo out a link

Post by Goofan »

Now it works! It were a bug =) dont really know how/what or why but it works =)
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: echo out a link

Post 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.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: echo out a link

Post by Goofan »

nah think it were with my Wampserver... i had to reinstall it =)
Post Reply