scheols Posted June 22, 2006 Share Posted June 22, 2006 Alright how can i set a cookie for my guest.What it will do:Im making another part to my code to interact with this Form check to see if the guest or member has intered the correct password to view forum. But as i can tell before doing this it will requir you to constantly send u to inter password to view topics and etc..Question: now how can i make it so it sets a cookie for the password so when my forum check form code interacts on if that person has entered the password its stored and you dont have to keep going back to inter password.2nd question:Can I like grab a location or edit forum file(thats interred into the forum php files threw ftp and uploaded) and do a If Statement and testing if my form has had the password intered and correct and not send him no where else it sends him back to the form page to enter the correct password and stores in his cookies so you dont have to keep going back to inter form password like i said in question 1.edt This code for Question one about the cookie.faccess.php page[code]<html><body><form action="faccesscheck.php" method="POST">Enter your name: <input type="text" name="name" />Enter your password: <input type="text" name="password" /><input type="submit"/></form></body></html>[/code]faccesscheck.php page[code]<?php$password = "acgranted";if($_POST[password] != $password){header("Location: accessnotgranted.php");}else {header("Location: somespeciallocation.php");}?>[/code]Note[somespeciallocation.php was a test and accessgranted is all HTML so no need to really look at that part] Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/ Share on other sites More sharing options...
trq Posted June 22, 2006 Share Posted June 22, 2006 I see your other thread was moved but, once again your question makes little to no sense.Maybe a read of the link in my signiture will give you a better understanding of how to form complete, coherent questions. Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48336 Share on other sites More sharing options...
scheols Posted June 22, 2006 Author Share Posted June 22, 2006 right now all i want to do is make it so that the password (if true) sets a cookie to the user saving that password for later use.Understand?Im not perfect. Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48339 Share on other sites More sharing options...
trq Posted June 22, 2006 Share Posted June 22, 2006 Its not wise to store passwords in cookies...[code]if ($pass) { set_cookie("password",$pass);}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48340 Share on other sites More sharing options...
legohead6 Posted June 22, 2006 Share Posted June 22, 2006 [!--quoteo(post=386696:date=Jun 21 2006, 09:14 PM:name=scheols)--][div class=\'quotetop\']QUOTE(scheols @ Jun 21 2006, 09:14 PM) [snapback]386696[/snapback][/div][div class=\'quotemain\'][!--quotec--]Alright how can i set a cookie for my guest.What it will do:Im making another part to my code to interact with this Form check to see if the guest or member has intered the correct password to view forum. But as i can tell before doing this it will requir you to constantly send u to inter password to view topics and etc..Question: now how can i make it so it sets a cookie for the password so when my forum check form code interacts on if that person has entered the password its stored and you dont have to keep going back to inter password.2nd question:Can I like grab a location or edit forum file(thats interred into the forum php files threw ftp and uploaded) and do a If Statement and testing if my form has had the password intered and correct and not send him no where else it sends him back to the form page to enter the correct password and stores in his cookies so you dont have to keep going back to inter form password like i said in question 1.edt This code for Question one about the cookie.faccess.php page[code]<html><body><form action="faccesscheck.php" method="POST">Enter your name: <input type="text" name="name" />Enter your password: <input type="text" name="password" /><input type="submit"/></form></body></html>[/code]faccesscheck.php page[code]<?php$password = "acgranted";if($_POST[password] != $password){header("Location: accessnotgranted.php");}else {header("Location: somespeciallocation.php");}?>[/code]Note[somespeciallocation.php was a test and accessgranted is all HTML so no need to really look at that part][/quote]umm..i would use sessions as there abit simpler! to set a session you fist need SESSION_START(); and the very top pf your page on line 1 (IE. <? SESSION_START(); ?>) then use the code below[code]<?php$password = "acgranted";if($_POST[password] != $password){header("Location: accessnotgranted.php");}else {header("Location: somespeciallocation.php");$_SESSION['name'] = $name;}?>[code]Then to retrive it on the next page you need the start on line one then$name=$_SESSION['name']; Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48344 Share on other sites More sharing options...
scheols Posted June 22, 2006 Author Share Posted June 22, 2006 so what would I repplace the session name as? the stored password? can u go in depth with the detials?[!--quoteo(post=386704:date=Jun 21 2006, 09:39 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 21 2006, 09:39 PM) [snapback]386704[/snapback][/div][div class=\'quotemain\'][!--quotec--]Its not wise to store passwords in cookies...[code]if ($pass) { set_cookie("password",$pass);}[/code][/quote]whitch will be the pass and whitch wil be the varible can u explain this plz. Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48347 Share on other sites More sharing options...
legohead6 Posted June 22, 2006 Share Posted June 22, 2006 [!--quoteo(post=386711:date=Jun 21 2006, 09:53 PM:name=scheols)--][div class=\'quotetop\']QUOTE(scheols @ Jun 21 2006, 09:53 PM) [snapback]386711[/snapback][/div][div class=\'quotemain\'][!--quotec--]so what would I repplace the session name as? the stored password? can u go in depth with the detials?whitch will be the pass and whitch wil be the varible can u explain this plz.[/quote]$_session['name'] = $var;name is where you name the info to acess later so pass or something and the $var is the data(so password) Quote Link to comment https://forums.phpfreaks.com/topic/12605-setting-cookies-for-my-form-and-soem-other-questions/#findComment-48355 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.