karker Posted May 6, 2011 Share Posted May 6, 2011 hi everybody ; its working Forgot Password i am posting a form.php to anohter page.php and if turn true i am sending mail and creating a cookie after header(Location: form.php) so cookie code in page.php ob_start() sessioon_start $_COOKIE['mailsent'] = $mailii; setcookie("mailsent",$mailii,time()+(60*30)); i want show it if(isset($_Cookie['mail'])) { echo "sent mail to $_Cookie['mailsent']" } but i am taking this Notice Notice: Undefined index: kayip in J:\EasyPHP-5.3.2i\twww\site\form.php on line 133 when i lookup to site Cookies i am allready seem "mailsent" and value = $dynamic_mail so where am i doing wrong ?? Quote Link to comment Share on other sites More sharing options...
spiderwell Posted May 6, 2011 Share Posted May 6, 2011 which is line 133 sessioon_start? typo? which cookie is it? mail or mailsent? Quote Link to comment Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 I agree with spiderwell we need to know the line that has kayip in it. One thing you may already know but you can't set a cookie and read a cookie in the same execution of a script. i.e you must run the script and set the cookie then run the script again to read it regardless how you do it. incubi1 Quote Link to comment Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 so kayip is another # language mean mail .. i used mailsent if(isset($_Cookie['mailsent'])) { echo "sent mail to $_Cookie['mailsent']" } Notice: Undefined index: mailsent in J:\EasyPHP-5.3.2i\twww\site\form.php on line 133 in 133 line : echo $_COOKIE['mailsent'] ; Quote Link to comment Share on other sites More sharing options...
spiderwell Posted May 6, 2011 Share Posted May 6, 2011 dude! upload the whole code, or give us a larger amount of it, its very had to tell what is going on. line 133 is basically saying the cookiee doesnt exist yet, so as the incubi above stated, you probably have set it, and then try and read it in the same execution of script Quote Link to comment Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 this is form.php if(isset($_GET['islev'])) { $islem = $_GET['islev']; switch($islem) { line33 . case 'ok' : $table ='.$_COOKIE['mailsent'].';break; case 'fail' : $table = 'form element posting another page and setcookie ;break; } } <body> echo $table </body> posted page.php ob_start(); session_start(); if(isset($posted)) { mail($,$,$,$); setcookie("kayip",$mailii,time()+(60*30)) ; $_COOKIE['mail_sent'] = $row['mail_adres']; } ob_end_flush() ; allready seem mailsent Cookie in firefox but i am taking Notice: Undefined index: mailsent in J:\EasyPHP-5.3.2i\www\ct\forgot_pass.php on line 133 i didint understand so :S where wrong Quote Link to comment Share on other sites More sharing options...
spiderwell Posted May 6, 2011 Share Posted May 6, 2011 your original post: hi everybody ob_start() sessioon_start $_COOKIE['mailsent'] = $mailii; setcookie("mailsent",$mailii,time()+(60*30)); your latest copy of the supposedly same code: setcookie("kayip",$mailii,time()+(60*30)) ; $_COOKIE['mail_sent'] = $row['mail_adres']; you have changed your setcookiee variable the error is stating it cant find the mailsent cookiee, and the reason is as incubi first stated. Although now it looks like you don't even set it at all. set a cookiee it cannot be called until after a page script ends. setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. Once the cookies have been set, they can be accessed on the next page load .... read this for more info http://php.net/manual/en/function.setcookie.php also i don't think this line does anything: $_COOKIE['mail_sent'] = $row['mail_adres']; as = is assignment operator and im pretty sure it doesnt apply to setting cookiee values Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.