-
Posts
205 -
Joined
-
Last visited
Everything posted by Tom8001
-
I'm new to PHP
-
the only error i have is Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\xampp\htdocs\Login\connect.phpon line 15 & It still says username or password is incorrect when trying to login.
-
Also i'm not using MySQLi, i think it's stupid MySQL can do everything i need it to do i don't even know why they added sqli
-
Login script <?php error_reporting(E_ALL | E_NOTICE); require 'connect.php'; session_start(); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; if(empty($username)) { echo "You did not enter a username, Redirecting..."; echo "<meta http-equiv='refresh' content='2' URL='login.php'>"; exit(); } else if(empty($password)) { echo "You did not enter a password, Redirecting..."; echo "<meta http-equiv='refresh' content='2' URL='login.php'>"; exit(); } //Prevent hackers from using SQL Injection to hack into Database $md5_password = md5(trim($_POST['password'])); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); $row = mysql_fetch_assoc($result); $user_level = $row['user_level']; if($count == 1) { $_SESSION['loggedIn'] = true; $_SESSION['username'] = $_POST['username']; } Registration script <?php error_reporting(E_ALL | E_NOTICE); require 'connect.php'; echo "<title> Register </title>"; if(isset($_POST['submit'])) { if (isset($_POST['username']) && isset($_POST['password'])){ $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $username = mysql_real_escape_string($username); $email = mysql_escape_string($email); $password = mysql_real_escape_string($password); $usrsql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$md5_password'"; $usrres = mysql_query($usrsql); if (!$usrres) { die("Query Failed."); } if (mysql_num_rows($usrres) > 0) { echo "<style>body {background-image: url('http://desktopwallpapers.biz/wp-content/uploads/2014/09/Website-Background-Cool-HD.jpg');} #uexist {position: fixed;top: 200px;left: 550px; font-size: 24px;}</style>"; die("<font color='yellow' face='Tahoma'> <b> <center> <p id='uexist'> The username you entered is already in use. </p> </center> </b> </font>"); } else { // DO NOTHING } if(empty($username)) { print("<font color='red'>You did not enter a username!</font> <br> <br>"); } else if(empty($password)) { die("<font color='red'>You did not enter a password!</font>"); } if(strlen($username)<3) { die("<font color='red'>Your username must be over 3 characters!</font>"); } else if(strlen($username)>20) { die("<font color='red'>Your username is over 20 characters and must be under! usernames are 3 - 20 characters!</font>"); } if(isset($_POST['email']) && filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL)) { $email = trim($_POST['email']); } $md5_password = md5(trim($_POST['password'])); $query = "INSERT INTO `x_users` (username, password, email) VALUES ('$username', '$md5_password', '$email')"; $result = mysql_query($query); if($result == 1) { print("Thank you, your accout has been created!"); } } } ?>
-
i can get it to insert the md5 password into the database but then it wont login.
-
i did that, now it doesn't insert anything into the database.
-
it didn't work
-
in my login script i used if(isset($_POST['submit']) i'll add it to my register script
-
I Used the code below & The script works fine with that, but my only problem now is encrypting my passwords i can't get it to work, when they register it goes into the database as md5() but when trying to login it says username or password is incorrect. if (isset($_POST['username']) && isset($_POST['password'])){
-
It says this on PHP.net " " (ASCII 32 (0x20)), an ordinary space. "\t" (ASCII 9 (0x09)), a tab. "\n" (ASCII 10 (0x0A)), a new line (line feed). "\r" (ASCII 13 (0x0D)), a carriage return. "\0" (ASCII 0 (0x00)), the NUL-byte. "\x0B" (ASCII 11 (0x0B)), a vertical tab. But i don't understand what they are
-
I have SQL Injection code in the login script but not registration and i already have & i always use error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_NOTICE); Here's my login <?php error_reporting(E_ALL | E_NOTICE); require 'connect.php'; session_start(); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = md5($_POST['password']); if(empty($username)) { echo "You did not enter a username, Redirecting..."; echo "<meta http-equiv='refresh' content='2' URL='login.php'>"; exit(); } else if(empty($password)) { echo "You did not enter a password, Redirecting..."; echo "<meta http-equiv='refresh' content='2' URL='login.php'>"; exit(); } //Prevent hackers from using SQL Injection to hack into Database $md5_password = md5($_POST['password']); $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$encrypt_password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); $row = mysql_fetch_assoc($result); $user_level = $row['user_level']; if($count == 1) { $_SESSION['loggedIn'] = true; $_SESSION['username'] = $_POST['username']; } else { print("<br> <br>Username / Password is Incorrect!"); exit(); }
-
It inserts the md5 into the password field in the database but it wont work when logging in.
-
This is my code it's not working. $username = $_POST['username']; $password = $_POST['password']; $encrypt_password = md5($password); $email = $_POST['email']; $usrsql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$encrypt_password'"; //--> Below is the INSERT Code $query = "INSERT INTO `x_users` (username, password, email) VALUES ('$username', '$encrypt_password', '$email')"; $result = mysql_query($query); if($result == 1) { print("Thank you, your accout has been created!"); } Can anyone tell me why the md5() function is not working?
-
<div id="img"> <center> <img src="pic.png" /> </center> </div> <style>body {background-image: url('http://desktopwallpapers.biz/wp-content/uploads/2014/09/Website-Background-Cool-HD.jpg')} #img {background-color: #000; margin-top: 40px; box-shadow: 5px 0px 5px 0px #ff0000; display: block; width: auto;}</style> This is my code
-
No?, i said i want a box shadow going around the image but the box-shadow does not fit around the image, on the right & left side of the image there is extra space i want to get rid of to make it fit around the image properly.
-
You could put it inside a div & use CSS <div id="name"> your table here </div> <style> #name {position: absolute;} </style> That should keep it in one place.
-
i have an image and i want a box shadow around the image but instead of going around the image the width on both left & right goes to the end of the page, does anyone know how i can get the box shadow to just go around the image?
-
This works great!, thanks all for your help
-
hi, how can i check if a username exists? i tried this $usrsql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'"; $usrres = mysql_query($usrsql); $usrcount = mysql_num_rows($usrres); if($usrres && mysql_num_rows($usrcount)>0) { die("Username is already taken!"); }
-
Ok so i have a query that gets all the usernames from the database and i have echoed them out. i want make a button next to it that can ban / unban the user but what i am confused about is how would i select that user?
-
I can link you the files if you want?