-3

The issue says unexpected {..... I dont understand why this is hapenning i remove it and i still ahve issues. Please reply with th right code.

Kevin Andrews / Auth

<?php

$shortenedlink = mt_rand(10000,99999);
$longlink = $_POST['longlink'];
if(!isset($longlink) || trim($longlink) == '')
{
   echo "The link field is empty. Redirecting you in 3 seconds.";
   header ( "refresh:3;url=http://auth.kenygamer.com" );
   exit;

$shortenedlinkpath = "$shortenedlink.asp";
if (file_exists($shortenedlinkpath))
{
    echo "An error occurred creating the shortened link, because the assigned number already exists. However, you can retry. Copy the link and paste it again on the main page:<br><br>$longlink<br><br>Redirecting you in 15 seconds.";
    header( "refresh:15;url=http://auth.kenygamer.com" );
    exit;

}
else
{
    echo "";
}

$shortenedfilecontent = '<title>Outgoing link</title><meta http-equiv="refresh" content="5; url=$longlink">';
$fp = fopen("$shortenedlink.asp", "w"); 
fwrite($fp, $shortenedfilecontent).'&nbsp;'; 
fclose($fp);

echo ("The shortened URL has been successfully created. The shortened number #$shortenedlink has been assigned to your long URL $longlink. Therefore, it is accessible at https://auth.kenygamer.com/$shortenedlink at any time. Remember that you can always create new shortened URLs.<br><br>Long link: $longlink<br>Shortened link: $shortenedlink<br><br>Redirecting you in 20 seconds.");
header( "refresh:20;url=https://auth.kenygamer.com/$shortenedlink" );
?>
Kevin
  • 29
  • 5

1 Answers1

1

You forgot to add the } after the exit;

This should help you:

<?php

$shortenedlink = mt_rand(10000, 99999);
$longlink = $_POST['longlink'];
if (!isset($longlink) || trim($longlink) == '') {
    echo "The link field is empty. Redirecting you in 3 seconds.";
    header("refresh:3;url=http://auth.kenygamer.com");
    exit;
}

$shortenedlinkpath = "$shortenedlink.asp";
if (file_exists($shortenedlinkpath)) {
    echo "An error occurred creating the shortened link, because the assigned number already exists. However, you can retry. Copy the link and paste it again on the main page:<br><br>$longlink<br><br>Redirecting you in 15 seconds.";
    header("refresh:15;url=http://auth.kenygamer.com");
    exit;
} else {
    echo "";
}

$shortenedfilecontent = '<title>Outgoing link</title><meta http-equiv="refresh" content="5; url=$longlink">';
$fp = fopen("$shortenedlink.asp", "w");
fwrite($fp, $shortenedfilecontent) . '&nbsp;';
fclose($fp);

echo ("The shortened URL has been successfully created. The shortened number #$shortenedlink has been assigned to your long URL $longlink. Therefore, it is accessible at https://auth.kenygamer.com/$shortenedlink at any time. Remember that you can always create new shortened URLs.<br><br>Long link: $longlink<br>Shortened link: $shortenedlink<br><br>Redirecting you in 20 seconds.");
header("refresh:20;url=https://auth.kenygamer.com/$shortenedlink");
?>
  • or anyone, This code is not working can you fix it http://auth.kenygamer.com

    Redirecting you in 10 seconds.'; header( "refresh:10;url=http://auth.kenygamer.com" ); exit; } else { echo ""; }
    – Kevin Mar 18 '17 at 23:43