Skip to content

Instantly share code, notes, and snippets.

@sunlee-newyork
Created November 16, 2013 21:33
Show Gist options
  • Save sunlee-newyork/7505635 to your computer and use it in GitHub Desktop.
Save sunlee-newyork/7505635 to your computer and use it in GitHub Desktop.
Website NONAME / ACTIVATE
<?php
session_start();
if (isset($_SESSION["user"])) {
header("Location: /IDEA/dashboard/index.php");
}
?>
<html>
<head>
<title>ACTIVATE</title>
<?php require $_SERVER['DOCUMENT_ROOT']."/IDEA/header/index.php"; ?>
<style>
#title {
font-family:HelveticaNeue-Light;
font-size:28px;
margin-top:100px;
text-align:center;
}
#text {
font-family:HelveticaNeue-Light;
font-size:16px;
margin-top:70px;
text-align:center;
}
</style>
</head>
<body>
<div id="title">Please activate your account.</div>
<div id="text">
<p>
We have sent you an email not too
<br>long ago with an activation link.
<br>Please click on the link, and if
<br>that doesn't work, please copy and
<br>paste the link into your browser.
<br><br><br><br>
<br>Thank you!
</p>
</div>
</body>
</html>
<?php
// === GET THE URL === \\
if ($_GET) {
echo "GET successful.";
// GET activation link and code
$activation = $_GET["activation"];
$username = $_GET["username" ];
// Match activation link username to DB
$query = mysql_query("SELECT `validate`,`username` FROM `signup` WHERE `validate` = '$activation' AND `username` = '$username';");
// If match exists:
if ($query) {
echo "Query successful.";
mysql_free_result($query);
// Change validation to TRUE
$query = mysql_query("UPDATE `signup` SET `validate` = true WHERE `username` = '$username';");
mysql_free_result($query);
// Check if user is validated.
$query = mysql_query("SELECT `validate`,`username` FROM `signup` WHERE `validate` = 1 AND `username` = '$username';");
while ($row = mysql_fetch_assoc($query)) {
echo "Row successful.";
// If validated:
if ($row["validate"] = 1) {
echo "Validate successful.";
// Start user session (log them in)
$_SESSION["user"] = "Done";
}
}
} else die("DIDN'T WORK DUDE.");
// Wrap it up team
mysql_free_result($query);
echo "<script>location.reload();</script>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment