SHOW:
|
|
- or go back to the newest paste.
1 | - | <?php |
1 | + | <!-- This Is To Call Username/Password --> |
2 | ||
3 | <!-- | |
4 | - | $link = mysql_connect('bondsolutionsnjcom.fatcowmysql.com', 'lightswitch', '*password*'); |
4 | + | <form method="post" action="#" id="login"> |
5 | - | if (!$link) { |
5 | + | <input type="text" name="username" id="username" /> |
6 | - | die('Could not connect: ' . mysql_error()); |
6 | + | <input type="password" name="password" id="password" /> |
7 | - | } |
7 | + | <input type="submit" value="Login" id="submit" /> |
8 | - | echo 'Connected successfully'; |
8 | + | </form> |
9 | --> | |
10 | <?php | |
11 | function main($formUse = true) | |
12 | - | $username; |
12 | + | |
13 | - | $password; |
13 | + | $link = mysql_connect('bondsolutionsnjcom.fatcowmysql.com', 'lightswitch', '*password*'); |
14 | if (!$link) { | |
15 | - | if(!$username || !$password) { |
15 | + | die('Could not connect: ' . mysql_error()); |
16 | } | |
17 | - | echo "Login or password cant be empty."; |
17 | + | echo 'Connected successfully'; |
18 | mysql_select_db('red_light_life_accounts1'); | |
19 | - | } else { |
19 | + | |
20 | // This could be supplied by a user, for example | |
21 | ||
22 | $username = $_POST['username']; //Called By The Post, $_POST Is the Global variable to use | |
23 | $password = $_POST['password']; //Called By The Post, $_POST Is the Global variable to use | |
24 | $errors = array(); | |
25 | ||
26 | if(isset($POST['submit'])){ | |
27 | if(!$username){ | |
28 | $errors[] = "Username Can Not Be Empty"; | |
29 | } | |
30 | - | |
30 | + | if(!$password){ |
31 | - | $count = strlen($password); |
31 | + | $errors[] = "Password Can Not Be Empty"; |
32 | - | $count2 = strlen($datas['passwird']); |
32 | + | } |
33 | } | |
34 | ||
35 | $dothis = count($errors); | |
36 | - | echo "Success"; |
36 | + | |
37 | if($dothis = 0){ | |
38 | $SQL = "SELECT * FROM accounts WHERE username = '$username' & password = '$password'"; | |
39 | $result_id = @mysql_query($SQL) or die("DATABASE ERROR!"); | |
40 | - | echo "Username or password is wrong."; |
40 | + | |
41 | if($total >= 1) { | |
42 | - | } |
42 | + | |
43 | $count = strlen($password); | |
44 | $count2 = strlen($datas['passwird']); | |
45 | if(!strcmp($count, $count2)) { | |
46 | echo "Success"; | |
47 | } else { | |
48 | echo "Username or password is wrong."; | |
49 | } | |
50 | - | } |
50 | + | |
51 | ||
52 | echo "Data invalid - cant find username."; | |
53 | ||
54 | } | |
55 | ||
56 | }else{ | |
57 | foreach($errors as $display){ | |
58 | echo $display; | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
63 | // Close mySQL Connection | |
64 | ||
65 | mysql_close(); | |
66 | ?> |