I tried with this code but it's not working, Show
asked Dec 25, 2013 at 6:10
1 You can't use php code client-side. You need to use javascript.
However, you really shouldn't be using inline js (like onclick here). Study about this here: https://www.google.com/search?q=Why+is+inline+js+bad%3F Here's a clean way of doing this: Live demo (click). Markup:
JavaScript:
If you need to write in the location with php:
answered Dec 25, 2013 at 6:12
m59m59 42.6k14 gold badges115 silver badges134 bronze badges Why do people keep confusing php and javascript? PHP is SERVER SIDE You will have to use just javascript to redirect. Otherwise if you want PHP involved you can use an AJAX call to log a hit or whatever you like to send back a URL or additional detail. answered Dec 25, 2013 at 6:13
JakubJakub 20.3k8 gold badges64 silver badges92 bronze badges Please try this
window.location.href example:
window.open() example:
answered Dec 25, 2013 at 6:16
Sudheesh.RSudheesh.R 3362 silver badges8 bronze badges you are using Javascript
Or PHP create another page as redirect.php and put
and insert this link on any page within the same directory
hope this helps its simplest!!
answered Dec 25, 2013 at 6:16
NullNull 1541 silver badge14 bronze badges Problem " /> Solution <?php header("Location: /start.php"); Markup Start var btn = document.getElementById('btnStart'); Start ’”>Start Start Markup Start var btn = document.getElementById('btnStart'); '">Start How do I make a button redirect to another page?To make button type submit redirect to another page, You can use HTML Anchor tags <a>. Where you need to write your HTML Button [button type submit] between these HTML Anchor Tag's starting <a> and Closing </a> Tags. or you can use HTML Form Tags to do the Same thing.
How can I link a PHP page to another page in PHP?Answer: Use the PHP header() Function
You can simply use the PHP header() function to redirect a user to a different page. The PHP code in the following example will redirect the user from the page in which it is placed to the URL http://www.example.com/another-page.php . You can also specify relative URLs.
How do I redirect a clicked button?How to Redirect to Another Page in JavaScript on button click. document. getElementById("myButton"). onclick = function () { location. href = "example.com"; };. function redirect() { let url = "http://example.com"; window. location(url); }. myFun(){ $('form'). attr('action','new path'); }. How do you redirect to another page on clicking a link in HTML?To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page. The <head> section of an HTML document contains metadata that is useful for the browser, but invisible to users viewing the page.
|