Reputation: 96
I am a beginner for this language and I don't know how to call another page or link in other page please help how?
Upvotes: 0
Views: 2326
Reputation: 1
A basic link is created by wrapping the text (or other content, see Block level links) you want to turn into a link inside an element, and giving it an href attribute (also known as a Hypertext Reference , or target) that will contain the web address you want the link to point to
Upvotes: 0
Reputation: 450
You can combine PHP and HTML together.
If you need a hyperlink in your page, you can either echo the html tags or embed the PHP code inside the HTML
Below is an example how I embedded the PHP inside the HTML tags
<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body style="width:1250px;">
<div>
<ul>
<li><a href="welcome.php">Home</a></li>
<?php if (isset($_SESSION['user'])) { ?>
<li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">Account</a>
<div class="dropdown-content">
<a href="profile.php">Profile</a>
<a href="articles.php">My Articles</a>
</div>
</li>
</li>
<li style="float:right"><a href="logout.php">Logout</a></li>';
<?php } else { ?>
<li style="float:right"><a href="register.php">Register</a></li>
<li style="float:right"><a href="login.php">Login</a></li>';
<?php } ?>
</ul>
</div>
</body>
And below is the example of how to use html tags inside the PHP code:
<?php
echo "<html>";
echo "<title>HTML with PHP</title>";
echo "<b>My Example</b>";
print "<i>Print works too!</i>";
?>
For page redirects, you can use the below code in your PHP :
header('location: targetfile.php');
Upvotes: 2
Reputation: 1
The PHP code located after the header() will be interpreted by the server, even if the visitor moves to the address specified in the redirection. In most cases, this means that you need a method to follow the header() function of the exit() function in order to decrease the load of the server:
<?php header('Location: /directory/mypage.php'); ?>
Upvotes: 0