Jump to content

Setting Cookies for my form and Soem other Questions


scheols

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]
Link to comment
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.
Link to comment
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'];
Link to comment
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.
Link to comment
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)
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.