Jump to content

Recommended Posts

hello, might be a stupid question but can you put an if and else inside of if brackets like i have done in this script?


<?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);


$sql = "select * from Wish_list_guest where usercookie='$rand_wish_cookie' and uinwish='$uinwish'";     //search db has the profile already been added to favorites
$result = mysql_query($sql);


$row = mysql_fetch_row($result);
if (mysql_num_rows($result)!= 1) {    //if 1 of more results found profile already added redirect back!


//Re-direct back script!!
if (!isset ($wishrefer)){

$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;

}


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

//end redirect script

else {

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'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;

}


else {
header('Location: $wishrefer');
exit;

}


?>

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.