getkey.php
Code: Select all
<?php
require_once 'dbinfo.php';
// database connection
$id = $_GET['id'];
// do some validation here to ensure id is safe
$link = mysql_connect($servername, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT ukey FROM keycode WHERE id=$id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
header("Content-type: image/png");
echo $row['ukey'];
?>key.php
Code: Select all
<html>
<head>
<title>Your Key Is Ready</title>
</head>
<body>
<center><p>Your key is</p>
<img src="getkey.php?id=1" width="175" height="50" /><br />
<p>You can redeem your key at $source</p>
</center>
</body>
</html>
index.php
Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<section id="mid_section">
<div id="boxes">
<h1>
Testing input key
</h1>
<br/>
<form id="myform" action="givekey.php" method="post">
Key:<br />
<input type="text" value="ukey">
Source:<br />
<input type="radio" value="hb">HB<br />
<input type="radio" value="ig">IG<br />
<input type="radio" value="other">Other<br />
<button id="sub">Submit</button>
</form>
</body>
</html>
givekey.php
Code: Select all
<?php
include_once('dbinfo.php');
$conn = mysql_connect($servername, $username, $password);
$db= mysql_select_db($database);
$ukey =$_POST['ukey'];
$hb =$_POST['hb'];
$ig =$_POST['ig'];
$other =$_POST['other'];
$key = "INSERT INTO keycode (ukey) VALUES ('$ukey')";
$source ="INSERT INTO source (hb,ig,other) VALUES ('$hb','$ig','$other')";
if(mysql_query($key, $source));
?>