Jump to content


Photo

Setting Cookies for my form and Soem other Questions


  • Please log in to reply
6 replies to this topic

#1 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 22 June 2006 - 02:14 AM

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
<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>

faccesscheck.php page
<?php
$password = "acgranted";
if($_POST[password] != $password){
header("Location: accessnotgranted.php");
}
else {
header("Location: somespeciallocation.php");
}
?>

Note[somespeciallocation.php was a test and accessgranted is all HTML so no need to really look at that part]
Dont Piss me Off today

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 02:26 AM

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.

#3 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 22 June 2006 - 02:32 AM

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.
Dont Piss me Off today

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 02:39 AM

Its not wise to store passwords in cookies...
if ($pass) {
  set_cookie("password",$pass);
}


#5 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 22 June 2006 - 02:44 AM

[!--quoteo(post=386696:date=Jun 21 2006, 09:14 PM:name=scheols)--][div class=\'quotetop\']QUOTE(scheols @ Jun 21 2006, 09:14 PM) View Post[/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
<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>

faccesscheck.php page
<?php
$password = "acgranted";
if($_POST[password] != $password){
header("Location: accessnotgranted.php");
}
else {
header("Location: somespeciallocation.php");
}
?>

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=auto:0]
<?php
$password = "acgranted";
if($_POST[password] != $password){
header("Location: accessnotgranted.php");
}
else {
header("Location: somespeciallocation.php");
$_SESSION['name'] = $name;
}
?>
[code=auto:0]


Then to retrive it on the next page you need the start on line one then

$name=$_SESSION['name'];

"Syntax error" .. WHERE THE **** IS IT?!

#6 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 22 June 2006 - 02:53 AM

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
Its not wise to store passwords in cookies...
if ($pass) {
  set_cookie("password",$pass);
}
[/quote]
whitch will be the pass and whitch wil be the varible can u explain this plz.
Dont Piss me Off today

#7 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 22 June 2006 - 03:59 AM

[!--quoteo(post=386711:date=Jun 21 2006, 09:53 PM:name=scheols)--][div class=\'quotetop\']QUOTE(scheols @ Jun 21 2006, 09:53 PM) View Post[/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)
"Syntax error" .. WHERE THE **** IS IT?!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users