I have URL which is sent to the given email. However, I would like user clicking that URL to be redirected to another URL.
I have tried the below code for sending mail,but I don't know how to create a URL which will redirect to another page.
<?php
$send_link=getLink("http://www.google.com",array("referral"=>"123","mobilenumber"=>"1234"));
echo $send_link;
function getLink($url,$params=array(),$use_existing_arguments=false)
{
if($use_existing_arguments) $params = $params + $_GET;
if(!$params) return $url;
$link = $url;
if(strpos($link,'?') === false) $link .= '?';
//If there is no '?' add one at the end
elseif(!preg_match('/(\?|\&(amp;)?)$/',$link)) $link .= '&';
//If there is no '&' at the END, add one.
$params_arr = array();
foreach($params as $key=>$value)
{
if(gettype($value) == 'array')
{
//Handle array data properly
foreach($value as $val)
{
$params_arr[] = $key . '[]=' . urlencode($val);
}
}
else
{
$params_arr[] = $key . '=' . urlencode($value);
}
}
$link .= implode('&',$params_arr);
return $link;
}
$user_id='1';
$get_referred_user=mysqli_query($con,"select * from Phone_Book_Email where contact_id='$user_id'");
if (mysqli_num_rows($get_referred_user) > 0)
{
while($row = mysqli_fetch_assoc($get_referred_user))
{
$email_id=$row['email_id'];
echo $email_id;
$to = $email_id;
$subject = 'test';
$message = 'URL- '.$send_link;
$headers = 'From: Hubster@hubster.com' . "\r\n" . 'Reply-To: Hubster@hubster.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
//header("Location:http://www.facebook.com");
//header("refresh: $time_in_seconds; url=http://www.facebook.com");
}
}
?>
Please suggest me guys what I have to do here for redirecting user clicking one url to another url.