Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 15th, 2007, 8:20 PM   #1
Kelvoron
Programmer
 
Kelvoron's Avatar
 
Join Date: Aug 2007
Location: Ohio
Posts: 46
Rep Power: 0 Kelvoron is on a distinguished road
releasing a veriable?

hey guys i am playing around with php trying to get a head start as i will be having a class on it in three weeks and i was wondering how to release a veriable? meaning i have a form you input what will eventuly become a pass word right now it is dog, and when you input dog, for the time beeing it says thank you for loging in, any other time it says sorry your not in the database, the problem i am having is once you hit submit and dog is the veriable $pass it will continue to stay as $pass when you refresh it. wich is a good thing in the long run, but i need to be able to release the veriable, or log out if you will.

heres my code:
<font class="phpexample">
<form method="post">
Yourname:<input type="text" name="pass">
<input type="submit" value="submit">
</form>
<?
$pass=$_POST['pass'];
if($pass == "dog")
{
print("Thank you for loging in");
}
else{
print("sorry not in data base");
}
?>

thanks in advanced
__________________
Good better best, never let it rest, untill your good is better and your better is the best.
Kelvoron is offline   Reply With Quote
Old Aug 15th, 2007, 8:33 PM   #2
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
You would normally want to have the login form submit to a new page. You don't really need to release anything, just set a session variable that the user is logged in and send them to whatever page necessary.
__________________
JG-Webdesign
Wizard1988 is offline   Reply With Quote
Old Aug 15th, 2007, 8:37 PM   #3
Kelvoron
Programmer
 
Kelvoron's Avatar
 
Join Date: Aug 2007
Location: Ohio
Posts: 46
Rep Power: 0 Kelvoron is on a distinguished road
okay. thanks
__________________
Good better best, never let it rest, untill your good is better and your better is the best.
Kelvoron is offline   Reply With Quote
Old Aug 15th, 2007, 10:06 PM   #4
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 841
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
To answer your question, you can use the unset function. Whether the data will be automatically resubmitted when the page is refreshed is browser-depended; in my browser (Safari on Mac OS X) it is not.

Your form should have an action attribute; you can set it to the name of the current page to replicate the current behavior:

<form method="post" action="filename.php" name="nameform">
Note that your form should also have a name attribute ("nameform" in the example above) to facilitate scripting.

Also note that the <font> tag is deprecated (use <div> or <span> instead). Additionally, you should close all tags, even those that do not require separate closing tags; for example:

<input type="submit" value="submit" />
Finally, you should check whether the form has been submit before printing a failure or success message by using the isset function; similarly, you may not want to display the form if the name is successfully found in the "database".

Last edited by titaniumdecoy; Aug 15th, 2007 at 10:27 PM.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC