richiejones24 Posted November 5, 2011 Share Posted November 5, 2011 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; } ?> Link to comment https://forums.phpfreaks.com/topic/250500-can-you-put-an-if-and-an-else-inside-of-an-if/ Share on other sites More sharing options...
yami007 Posted November 5, 2011 Share Posted November 5, 2011 what's wrong about that? I always did this <?php if ( ...) { if () { } else { } } ?> and so on... Link to comment https://forums.phpfreaks.com/topic/250500-can-you-put-an-if-and-an-else-inside-of-an-if/#findComment-1285224 Share on other sites More sharing options...
floridaflatlander Posted November 5, 2011 Share Posted November 5, 2011 All day Link to comment https://forums.phpfreaks.com/topic/250500-can-you-put-an-if-and-an-else-inside-of-an-if/#findComment-1285229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.