![]() |
Author : vcarter Creation : : on 03/08/2007 09:53:20 PM Last modification: : on 03/26/2007 01:34:40 AM Rate and comment this tutorial Print this tutorial |

)1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <!--Im making the form--> <form action="index.php" method="post"> <input type="text" name="login"> <input type="password" name="password"> <input type="submit" value="Send Now !"> </form> <!--The PHP code is in the same page (the form send the posts in this page)--> <?php //I check the login isn't null if(isset($_POST['login']) && !empty($_POST['login'])) { //For the security $login = htmlentities($_POST['login']); $password = htmlentities($_POST['password']); mysql_connect("localhost", "root", ""); // DB connection mysql_select_db("members_zone"); // Base choice $sql = mysql_query('SELECT count(*) FROM members WHERE pseudo = "'.$login.'" AND password = "'.$password.'"'); $data = mysql_fetch_array($sql); //I check the login and the password are correct (if the result > 0) if ($data[0] != 0) { //If they are correct, I create a session and I redirect the members to the members page $_SESSION['login'] = $login; $_SESSION['password'] = $password; header("location: members.php"); //I redirect to the members page } else { echo 'The password is wrong ! Retry !'; } } ?> |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <form action="inscription.php" method="post"> Login : <input type="text" name="login"></br> Password : <input type="password" name="password"></br> Retype password : <input type="password" name="password2"></br> <input type="submit" value="Send Now !"> <?php if (isset($_POST['login']) && !empty($_POST['login']) && isset($_POST['password']) && !empty($_POST['password'])) { //For the security $login = htmlentities($_POST['login']); $password = htmlentities($_POST['password']); $password2 = htmlentities($_POST['password2']); if ($password == $password2) //If the 2 password are the same { mysql_connect("localhost", "root", ""); // DB connection mysql_select_db("members_zone"); // Base choice $sql = mysql_query('INSERT INTO members VALUES("", "'.$login.'", "'.$password.'", "......other informations")'); //You must enter one information in all columns, it may be void. echo '</br>The inscription is finished ! You can connect to the members zone now !'; } else { echo '</br>The 2 password are different !'; } } else { echo 'Error, retry !'; } ?> |
1 2 3 4 5 6 7 8 9 10 11 | <?php //I check the session exists, if it doesn't exist, the member is redirect to index.php session_start(); //Don't forget that, else the member will be disconnected. if (!isset($_SESSION['login'])) { header("location: index.php"); } echo 'Welcome on my website '.$_SESSION['login'].' !</br> I hope you enjoy it !'; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php //I check the session exists, if it doesn't exist, the member is redirect to index.php session_start(); if (!isset($_SESSION['login'])) { header("location: index.php"); } mysql_connect("localhost", "root", ""); // DB connection mysql_select_db("members_zone"); // Base choice //I put all informations on a table $sql = mysql_query('SELECT * FROM members WHERE pseudo = "'.$_SESSION['login'].'"'); $data = mysql_fetch_array($sql); $password = $data['password']; //I find informations on this table $webmail = $data['webmail']; echo 'Welcome on my website '.$_SESSION['login'].' !</br> I hope you enjoy it !</br> Your password is "'.$password.'" and your webmail is "'.$webmail.'" !'; ?> |

Change your template |
Learn more about NP |
Site map |
Terms of use |
Rules |
RSS feed |
XHTML 1.0 |
CSS 2.0
Powered by Simple IT SARL:
Contact us
There is nothing else to read, you have to go up now !
Do you want to be published here? Contact us.
2 Newbies Connected |
7 Requests |
0.1035s (0.091s)