Open an HTML file with PHP buttons | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Open an HTML file with PHP buttons

Let's say I have 3 files: home.html, q-a.html and contact.html How do I (I am on the home.html) go to the contact.html by pressing a button using php

1st Mar 2019, 10:04 PM
Roel
Roel - avatar
7 Answers
+ 6
<?php echo "<button><a href='contect.html'>Contact</a></button>"; ?>
1st Mar 2019, 10:16 PM
Rowsej
Rowsej - avatar
+ 6
As far as I know, you can’t add PHP function to events. Only JS.
2nd Mar 2019, 1:28 AM
Rowsej
Rowsej - avatar
+ 4
You cannot use directly html/js?
1st Mar 2019, 10:11 PM
KrOW
KrOW - avatar
+ 4
Roel I dont know PHP very well. What i know is than PHP its used on SERVER side and you want do happens something on CLIENT side, then i dont think thats possible.
2nd Mar 2019, 6:32 AM
KrOW
KrOW - avatar
+ 2
And KrOW I mean I could use JS, but I want to practise a bit on php, so I'm trying to use very little to no JS where it's possible to replace it with php
1st Mar 2019, 11:03 PM
Roel
Roel - avatar
+ 2
Rowsej KrOW Thanks for answering my question. I might as well ask my teacher about it, but thanks for making it clearer for me
2nd Mar 2019, 7:17 AM
Roel
Roel - avatar
+ 1
So in this case with php it's better to use an <a> element, but is it possible to it with just a button and a php function? And is it possible to use onclick for a php function instead of js function?
1st Mar 2019, 11:02 PM
Roel
Roel - avatar