mysql - Is there a replacement header function? in PHP
Get the solution ↓↓↓I'm trying to create a PHP page that redirects to URLs When a user enters a PHP page, the page automatically redirects it to another page For example, if the user goes to http://mysite/test.php?uid=044A7232214B80 The code will look for the uid that is in the domain in the phpMyAdmin tables and if there is a match the code directs the user to a URL that is also stored in the phpMyAdmin tables. I tried to use the header function problem that it only works with Relative URL (It searches the domain in relation to the current page) and I want it to work with domain addresses that directs the user to an external site
<?php
$servername = "localhost";
$dBUsername = "username";
$dBPassword = "password";
$dBName = "mysite";
$conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
// Check connection
if (!$conn) {
die("Connection failed: ".mysqli_connect_error());
}
//define variables
$uid = $_GET['uid']; //"044A7232214B80";
$sql = "SELECT URL FROM redirection_table WHERE UID = '$uid'";
$stmt = mysqli_stmt_init($conn);
//prepare statements
if (!$result = mysqli_stmt_prepare($stmt, $sql)){
exit();
}
else {
$row = mysqli_fetch_assoc($result);
if ($row){
$URL = $row['URL'];
if ($row['URL'] === null)
{
echo "Error:404";
}
else {
header("Location; '$URL'");
}
}
exit();
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illegal string offset
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.