Jump to content

data not being added to MySql DB


richiejones24

Recommended Posts

The script below used to work fine but the HTTP_REFERER was unreliable so i added a re-direct if the HTTP_REFERER was unavailable and now nothing is being added to the MySQL BD, the script runs ok ie it sends the user back to where they come from, any ideas what could be wrong? 

 


<?php
require("../include/mysqldb.php");
$uinwish = $_GET['uinwish'];
$wishrefer = $_SERVER['HTTP_REFERER'];
$wishdate  = mktime(0, 0, 0, date("m"), date("d")+3, date("Y"));
$rand_wish_cookie = $_COOKIE["wishtracking"];

$con = mysql_connect("$dbhost","$dbuser","$dbpass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("$dbame", $con);

//DB Stuff start code below

//check if the uin and cookie have already been stored together.
$sql = "select * from Wish_list_guest where usercookie='$rand_wish_cookie' and uinwish='$uinwish'";
$result = mysql_query($sql);


$row = mysql_fetch_row($result);
if (mysql_num_rows($result)!= 1) {

$issetvar = "1";

if (!isset ($wishrefer)){

$host  = $_SERVER['HTTP_HOST'];
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;
}

if (isset ($wishrefer)){

header("Location: $wishrefer");
exit;
}
}

if ($issetvar = 1) {

mysql_query("INSERT INTO Wish_list_guest (usercookie, date_delete, uinwish, referwish)
VALUES ('$rand_wish_cookie', '$wishdate', '$uinwish', '$wishrefer')");

mysql_close($con);


if (!isset ($wishrefer)){

$host  = $_SERVER['HTTP_HOST'];
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;
}

if (isset ($wishrefer)){

header("Location: $wishrefer");
exit;
}
}


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.