Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/projects/slutprojekt/

class/
create-categories.php
create-recipe.php
css/
db_content.php
forgot_password.php
include/
login.php
logout.php
recipe-search.php
recipe.php
reset_password.php
signin.php
start.php
tabeller/
verify.php

verify.php

33 lines UTF-8 Windows (CRLF)
<?php
include('../../dbconnection.php');
ob_clean();

if (isset(
$_GET['code'])) {
  
$verification_code $_GET['code'];

  
$stmt $dbconn->prepare("SELECT * FROM users WHERE verification_code = :code");
  
$stmt->bindParam(':code'$verification_code);
  
$stmt->execute();

  if (
$stmt->rowCount() > 0) {
    
$user $stmt->fetch(PDO::FETCH_ASSOC);
    
$expires strtotime($user['verification_expires']);

    if (
time() > $expires) {
      echo 
"Verifieringslänken har gått ut.";
      exit;
    }

    
$stmt $dbconn->prepare("UPDATE users SET is_verified = 1 WHERE verification_code = :code");
    
$stmt->bindParam(':code'$verification_code);
    
$stmt->execute();

    echo 
"E-postadressen har verifierats! Du kan nu <a href='login.php'>logga in</a>.";
  } else {
    echo 
"Ogiltig verifieringskod.";
  }
} else {
  echo 
"Ingen verifieringskod angiven.";
}
?>