tutorial for php and forms
Moderator: General Moderators
tutorial for php and forms
tutorial
Last edited by anmol on Sun Mar 14, 2004 11:23 pm, edited 2 times in total.
if you dont want to intergrate any databases/anything, how do you plan on storing the users name n password?
you can echo all the above, and the name in field one would have a variable name $var_name and when the user clicks submit, it will take them to a log.php page where u can use a simple if-statement could validate whether or not a user has type the correct password of not but I cant help you there cause i dont know how u plan on storing the names/passwords.
this is only a idea of how to do it but you need to figure out whtat u want to do to store the names
Code: Select all
<?php
<form action=log.php method=POST>
<input type=text name=var_name>
<input type=text name=var_pass>
<input type=submit value=Submit>
?>this is only a idea of how to do it but you need to figure out whtat u want to do to store the names
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
page they login from:
login.php
Then on any page you want to check if they're logged in:
Code: Select all
<html>
<body>
<form action="login.php" method="post">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>Code: Select all
<?PHP
session_start();
if($_POST['username']=="anmol" || $_POST['password']=="password"){
$_SESSION['username'] = $_POST['username'];
}
else {
echo "Incorrect Username or Password!";
}
?>Code: Select all
<?PHP
session_start();
if($_SESSION['username']=="anmol"){
//do stuff for logged in ppl
}
else {
//do stuff for ppl that aren't logged in
}
?>