Storm Spirit
Storm Spirit

Reputation: 1520

PHP Href have different url

I have phpmailer and the href have different value. When I inspect element, the URL are correct but when I click the Activate code the redirect will be different. enter image description here

This is my code:

$message = "
    <h2>Thank you for Registering.</h2>
    <p>Your Account:</p>
    <p>Email: ".$email."</p>
    <p>Password: ".$_POST['password']."</p>
    <p>Please click the link below to activate your account.</p>
    <a href='".$_SERVER['HTTP_HOST']."/activate.php?code=".$code."&user=".$userid."'>Activate Account</a>";

$mail = new PHPMailer(true);                             
try {
    //Server settings
    $mail->isSMTP();                                     
    $mail->Host = 'smtp.mailtrap.io';                      
    $mail->SMTPAuth = true;                               
    $mail->Username = 'e0891ddb9b14a1';     
    $mail->Password = '373f8f6c93f27d';                                         
    $mail->Port = 465;                                   

    $mail->setFrom('[email protected]');

    //Recipients
    $mail->addAddress($email);              
    $mail->addReplyTo('[email protected]');

    //Content
    $mail->Subject = 'ShopNow Sign Up';
    $mail->Body    = $message;
    $mail->isHTML(true);                                  

    $mail->send();

    unset($_SESSION['firstname']);
    unset($_SESSION['lastname']);
    unset($_SESSION['email']);

    $_SESSION['success'] = 'Account created. Check your email to activate.';
    header('location: signup.php');
} catch (Exception $e) {
    $_SESSION['error'] = 'Message could not be sent. Mailer Error: '.$mail->ErrorInfo;
    header('location: signup.php');
}

Upvotes: 1

Views: 60

Answers (1)

You forgot the https:// on the URL, so the browser interpreted it as a relative link.

Upvotes: 2

Related Questions