-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinserter_g_php.php
28 lines (28 loc) · 1.52 KB
/
inserter_g_php.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
session_start();
if (isset($_SESSION['username'])) {
include "connection.php";
$key = htmlspecialchars(mysqli_real_escape_string($link, $_POST['key']));
$des = htmlspecialchars(mysqli_real_escape_string($link, $_POST['des']));
$user_id = htmlspecialchars(mysqli_real_escape_string($link, $_POST['user']));
if (isset($_POST['submit'])) {
mysqli_query($link, "INSERT INTO `Gifts`(`code`, `des`) VALUES ('$key', '$des')") or die(mysqli_error($link));
$gift_id1 = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM `Gifts` WHERE `code` = '$key' AND `des` = '$des'"));
$gift_id = $gift_id1['id'];
mysqli_query($link, "INSERT INTO `Link`(`par_id`, `gift_id`) VALUES ('$user_id', '$gift_id')") or die(mysqli_error($link));
echo "<form action='summary.php' method='POST' id='form_refresh'>";
echo "<input type='hidden' id='refresh' name='refresh' value='refresh'>";
echo "</form>";
echo "<script>document.getElementById('form_refresh').submit()</script>";
}
}
else {
echo "<form action='index.php' method='POST' id='form_refresh'>";
echo "<input type='hidden' id='refresh' name='refresh' value='refresh'>";
echo "</form>";
echo "<script>document.getElementById('form_refresh').submit()</script>";
}
?>
<form action='index.php' method='POST' id='form'>
<input type='submit' value='home' id='submit' name='submit'>
</form>