Jump to content

Please help me with this processing


clown[NOR]

Recommended Posts

First of all. Admin, you can delete my post named "setcookie()....." starting over here

 

Now, over to the problem... I just dont understand why, but it just wont process this code:

<?php
	if (isset($phps_sbname)) { # Processed OK
		if (isset($_COOKIE['sbname'])) { # Prosessed OK
			if ($_COOKIE['sbname'] != $phps_sbname) { # Processed FAIL
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
			elseif ($_COOKIE['sbname'] == '') {
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
		}
		if (!isset($_COOKIE['sbname'])) {
			#setcookie("sbname", $phps_sbname, time()+31536000);
			#if ($phps_sburl != '') { setcookie("sburl", $phps_sburl, time()+31536000); }
			echo "New cookie would have been set";
		}
	}
}
?>

 

if you need more info, this is the whole code:

<?php
$phps_sbname = $_REQUEST['sbname'];
$phps_sburl = $_REQUEST['sburl'];
$phps_sbmessage = $_REQUEST['sbmsg'];

if ($phps_sbname == '') { echo 'Please enter a name'; }
elseif ($phps_sbmessage == '') { echo 'Please enter a message'; }
else {	
	if (isset($phps_sbname)) {
		if (isset($_COOKIE['sbname'])) {
			if ($_COOKIE['sbname'] != $phps_sbname) {
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
			elseif ($_COOKIE['sbname'] == '') {
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
		}
		if (!isset($_COOKIE['sbname'])) {
			#setcookie("sbname", $phps_sbname, time()+31536000);
			#if ($phps_sburl != '') { setcookie("sburl", $phps_sburl, time()+31536000); }
			echo "New cookie would have been set";
		}
	}
}

	if ($phps_sburl == '') {
		$phps_newshout = "\n<table border=0 width=100% cellspacing=0 cellpadding=0><tr><td bgcolor=#FFFFFF><strong>" . $phps_sbname . ":</strong> " . $phps_sbmessage . "</td></tr><tr><td bgcolor=#999999 height=1></td></tr></table>";
	}
	elseif ($phps_sburl != '') {
		$phps_newshout = "\n<table border=0 width=100% cellspacing=0 cellpadding=0><tr><td bgcolor=#FFFFFF><strong><a href=" . $phps_sburl . " target=_blank>" . $phps_sbname . "</a>:</strong> 	" . $phps_sbmessage . "</td></tr><tr><td bgcolor=#999999 height=1></td></tr></table>";
	}

	$phps_sbfh = fopen("file.txt", "ab");
	fwrite($phps_sbfh,$phps_newshout);
	fclose($phps_sbfh);
	Header("Location: http://www.nstclan.com/phpschool/v1.1/index.php");
?>

 

 

Link to comment
Share on other sites

the $_REQUEST is working fine here... the problem is that it just stops processing after

if ($_COOKIE['sbname'] != $phps_sbname) {

 

and skips everything that has to do with cookies and start again when it comes down to

if ($phps_sburl == '') {

 

then it finishes the script and adds the shout and everything like it should... it looks like it just ignores all of this:

<?php 
if ($_COOKIE['sbname'] != $phps_sbname) { # Processed FAIL
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
			elseif ($_COOKIE['sbname'] == '') {
				#setcookie("sbname", '', time()-31536000);
				#setcookie("sburl", '', time()-31536000);
				#unset($_COOKIE['sbname']);
				#unset($_COOKIE['sburl']);
				echo "Cookie would be unset()";
			}
		}
		if (!isset($_COOKIE['sbname'])) {
			#setcookie("sbname", $phps_sbname, time()+31536000);
			#if ($phps_sburl != '') { setcookie("sburl", $phps_sburl, time()+31536000); }
			echo "New cookie would have been set";
		}?>

Link to comment
Share on other sites

this is what I in return when i added the print_r($_COOKIE):

Array ( [sbname] => Clown [sburl] => http://www.phpschool.co.nr/ [phps_loginstate] => 1 [phps_loginuser] => ** [phpSESSID] => 4defbbb0767a4035b85bd3cc20f4a57e )

 

* = the username i use to login to my control panel =)

(proud about that... have made a fully functional CPanel on my site)

 

*EDIT* How do I know the path to where the cookie will be available?

 

I also think it's weird I would ahve to do that, since I don't need to do that on the other cookies I've made...

Link to comment
Share on other sites

Ok I added the cookie array to the "addshout" file and it returned:

Array ( [sbname] => Clown [sburl] => http://www.phpschool.co.nr/ [phps_loginstate] => 1 [phps_loginuser] => clown [phpSESSID] => 4defbbb0767a4035b85bd3cc20f4a57e )

Doesn't it say that the cookies "sbname" & "sburl" was added?

 

then I added the same array at the top of my index.php and it returned:

phps_loginstate => 1
phps_loginuser => clown
PHPSESSID => 4defbbb0767a4035b85bd3cc20f4a57e

 

no info about the sb cookies... what's going on with my cookies? give me my cookies back! bad computer!

Link to comment
Share on other sites

shit...that means i have to learn something new... hehe... think that will have to wait... 7.26am here now, havent been sleeping for about 17-18 hours .. hehe... been reading and studying php for all those hours =) fixing my CPanel... just figured out like 30 mins ago how to delete news, shouts and blog posts from the CPanel...

 

gonna read about sessions tomorrow after we've been visiting my fiance's parents...

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.