Jump to content

Archived

This topic is now archived and is closed to further replies.

scheols

Setting Cookies for my form and Soem other Questions

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Its not wise to store passwords in cookies...
[code]
if ($pass) {
  set_cookie("password",$pass);
}
[/code]

Share this post


Link to post
Share on other sites
[!--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'];

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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)

Share this post


Link to post
Share on other sites

×

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.