-
Posts
125 -
Joined
-
Last visited
Everything posted by Hazukiy
-
Hi, I have a question that's bugging me really badly, I want to make it so that when I have a <img> tag, the source of that image is shortened to look something like this... <img src="../../image.jpg" alt="picture_1" /> But when I do this, it doesn't work. I've tried many methods and different combination but it doesn't seem to work, so I figured that It must be some kind of option in the apache .htaccess file? Help would be much appreciated, thanks.
-
Ah that's it, I must of missed it out xD Thanks for the help.
-
Am I right in saying when that you want it so that when you hover over the tabs, it drops down a menu with your sub-tabs on them? If so I use jQuery for that. Here's the code I use for my site. $(document).ready(function(){ $(".al-menu-drop").parent().append("<span></span>"); $(".al-menu-drop").click(function() { $(this).parent().find(".al-dropdown-list").slideDown('fast').show(); $(".menu-icon").addClass("active-icon"); $(this).parent().hover(function() { }, function(){ $(this).parent().find(".al-dropdown-list").slideUp('slow'); $(".menu-icon").removeClass("active-icon"); }); }).hover(function() { $(this).addClass("jq-al-button-hover"); }, function(){ $(this).removeClass("jq-al-button-hover"); }); });
-
Oh sorry, the problem is that the salt isn't being added to the database, it's just left blank.
-
Hi, I've got some issues with my salting when I register... basically everything works fine apart from the salting and I can't get my head around it? Here's my php register function: public function register() { $correct = false; try { $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "INSERT INTO list_members(username, email, password) VALUES(:username, :email, :password)"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "username", $this->username, PDO::PARAM_STR ); $stmt->bindValue( "email", $this->email, PDO::PARAM_STR ); $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR ); $stmt->execute(); return header('Location: index.html'); }catch( PDOException $e ) { return $e->getMessage(); } } And then I have my public variables displayed like this: public $username = null; public $email = null; public $password = null; public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w"; Help would be much appreciated.
-
Hi, there's a site I saw which allows it's users to upload a link that will be implemented to the site. Now I was wondering but how would you do this in PHP? To elaborate I would like it so that the user can upload a link and it'll implement it on the site through php? So for example I want to add a link to the site WITHOUT having any kind of login required, so something like "www.google.com" and after it'll appear on the site under a list. How would I make it so it does this function? Thanks.
-
Sorry, what I meant was how do people create status sections? I would've though some PHP would be involved but would it be possible to just use ajax?
-
Hi, I'm just wondering but how do you do the status function? So you're able to create statuses? Is it Javascript or Html or anything like that? Thanks.
-
Hi, I'm trying to make a infinite picture cycle in jQuery; I know how to do it in Javascript but cross-referencing languages would be a little bit more harder so I'm wondering if they're a way I can do this in jQuery? Here's what I've attempted to do but doesn't work :/ Any ideas? Thanks. <script> $.seq = function() { $(this).fadeIn(2000); $(this).delay(5000); $(this).fadeOut(300, function() { $(this).next().seq(); }); return this; }; $(document).ready(function() { $("#picture_main_1").seq(); $("#picture_main_2").seq(); $("#picture_main_3").seq(); $("#picture_main_4").seq(); }); </script>
-
Ah ok, thanks.
-
Hi, I'm just wondering but what is the best of best kind of encryption that you can get when encrypting passwords? Like what does Facebook use? Thanks
-
Hi, I'm currently trying to understand exactly how php sessions work? So far I've been told that you start a session with session_start() and then hold that data in a variable like $_SESSION['User_Id']; but my problem is, is that I want it to hold the database user id so when the client logs in it keeps their session through their user_id. How would I execute this cause all the examples given to me look something like this: session_start(); $_SESSION['name'] = 'John';
-
I've now fixed the issue. It was because I forgot to add the data in and I also forgot to name the input forms.
-
Oh no I meant I just forgot to add it originally. Would this "cannot be null" error that I'm getting, wouldn't that be something to do with this as I'm declaring the variables as null and in the database it's set to not null? (Doing some troubleshooting on it now) public $firstname = null; public $lastname = null; public $username = null; public $email = null; public $password = null;
-
Ah sorry forgot to add this, it goes in the register.php. This goes at the top of the Register.php <?php if( !(isset( $_POST['register'] ) ) ) { ?> This goes at the bottom of the Register.php <?php } else { $usr = new Users; $usr->storeFormValues( $_POST ); if( $_POST['rpassword'] == $_POST['cpassword'] ) { echo $usr->register($_POST); } else { echo "Password and Confirm password not match"; } } ?>
-
I've recently changed a few things, here's the latest code: <?php class Users { public $firstname = null; public $lastname = null; public $username = null; public $email = null; public $password = null; public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w"; public function __construct( $data = array() ) { if( isset( $data['firstname'] ) ) $this->firstname = stripslashes( strip_tags( $data['firstname'] ) ); if( isset( $data['lastname'] ) ) $this->lastname = stripslashes( strip_tags( $data['lastname'] ) ); if( isset( $data['username'] ) ) $this->username = stripslashes( strip_tags( $data['username'] ) ); if( isset( $data['email'] ) ) $this->email = stripslashes( strip_tags( $data['email'] ) ); if( isset( $data['password'] ) ) $this->password = stripslashes( strip_tags( $data['password'] ) ); } public function storeFormValues( $params ) { $this->__construct( $params ); } public function userLogin() { $success = false; try{ $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "SELECT * FROM members WHERE username = :username AND password = :password LIMIT 1"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "username", $this->username, PDO::PARAM_STR ); $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR ); $stmt->execute(); $valid = $stmt->fetchColumn(); if( $valid ) { $success = true; } $con = null; return $success; }catch (PDOException $e) { echo $e->getMessage(); return $success; } } public function register() { $correct = false; try { $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "INSERT INTO members(firstname, lastname, username, email, password) VALUES(:firstname, :lastname, :username, :email, :password)"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "firstname", $this->firstname, PDO::PARAM_STR ); $stmt->bindValue( "lastname", $this->lastname, PDO::PARAM_STR ); $stmt->bindValue( "username", $this->username, PDO::PARAM_STR ); $stmt->bindValue( "email", $this->email, PDO::PARAM_STR ); $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR ); $stmt->execute(); return "Registration Successful <br/> <a href='index.php'>Login Now</a>"; }catch( PDOException $e ) { return $e->getMessage(); } } } ?> As you can see the $this variable should now work but it's still coming up with the same error. If I set my database structure to allow NULL the sign up works in the sense that it adds something to the database but of course it's just adding 'NULL' for everything. It's a bit weird this one, I've never come across this kind of error before ^.-
-
Which part?
-
Uhhh I'm not too sure :/
-
Hi, I'm in the middle of constructing my registration and login form and I keep getting this error when I try to process the login. Here's the error I'm getting: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'firstname' cannot be null Here's the PHP code: <?php class Users { public $firstname = null; public $lastname = null; public $username = null; public $email = null; public $password = null; public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w"; public function __construct( $data = array() ) { if( isset( $data['username'] ) ) $this->username = stripslashes( strip_tags( $data['username'] ) ); if( isset( $data['password'] ) ) $this->password = stripslashes( strip_tags( $data['password'] ) ); } public function storeFormValues( $params ) { $this->__construct( $params ); } public function userLogin() { $success = false; try{ $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "SELECT * FROM members WHERE username = :username AND password = :password LIMIT 1"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "username", $this->username, PDO::PARAM_STR ); $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR ); $stmt->execute(); $valid = $stmt->fetchColumn(); if( $valid ) { $success = true; } $con = null; return $success; }catch (PDOException $e) { echo $e->getMessage(); return $success; } } public function register() { $correct = false; try { $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "INSERT INTO members(firstname, lastname, username, email, password) VALUES(:firstname, :lastname, :username, :email, :password)"; $stmt = $con->prepare( $sql ); $stmt->bindValue( "firstname", $this->firstname, PDO::PARAM_STR ); $stmt->bindValue( "lastname", $this->lastname, PDO::PARAM_STR ); $stmt->bindValue( "username", $this->username, PDO::PARAM_STR ); $stmt->bindValue( "email", $this->email, PDO::PARAM_STR ); $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR ); $stmt->execute(); return "Registration Successful <br/> <a href='index.php'>Login Now</a>"; }catch( PDOException $e ) { return $e->getMessage(); } } } ?> My database layout is as follows Field Type Null Default Comments user_id int(11) No firstname varchar(50) No lastname varchar(50) No username varchar(50) No email varchar(50) No password var(250) No Indexes: Keyname Type Cardinality Field PRIMARY PRIMARY 0 user_id username UNIQUE 0 username email UNIQUE 0 email
-
So I really do think it's the hash not working so I'm just going to test some alternative methods for login & register forms and see if they work because I'm getting no where with this method.
-
Ah ok, thanks.
-
Hi, I was wondering but how would I make it so that people when on my site can't access certain files like 'footer.php' which is used as an include in PHP like so: include 'footer.php'; Basically I just want it so if the person tries to access domain.com/footer.php it'll return an error. Thanks.