Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my first time asking a question here so please bare with me if i mess up this question.

I Have made a form with HTML and PHP, users can enter their details and press submit and it comes back on a PHP page with their answers, including a URL. And it all comes back as plain text. What i would like to happen is for when they enter their URL it comes back as a hyperlink/clickable link.

What I have tried:

This is the code i have right now.
             $firstname = $_POST['firstname'];
             $course = $_POST['course'];
             $projecturl = $_POST['projecturl'];

             echo "<p>You are <span class='textblue'> $firstname</span> and ";
             echo "your course at the college is: <span class='textblue'> $course </span></p> ";
            echo "your project url is: <span class='textblue'> $projecturl</span></p> ";
Updated 13-Mar-23 10:56am
Richard Deeming 21-Feb-20 7:57am    
NB: You're going to want to HTML-encode that output, otherwise you'll introduce a cross-site scripting (XSS) vulnerability into your site.

Cross-Site Scripting (XSS) — Survive The Deep End: PHP Security :: v1.0a1[^]
PHP: htmlentities - Manual[^]

1 solution

You're looking for the A tag[^].
Share this answer
Double_Hitt 20-Feb-20 22:44pm    
Is it possible for you to explain further? do i just use the a tag in HTML and echo it out in PHP?
phil.o 21-Feb-20 4:25am    
echo "<a href='theurl'>the link</a>";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900