Jump to content

azonicds2

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

azonicds2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ignace you are a god! That worked brilliantly. Thank you very much for that. Very much appreciated! I had tried to use implode before but i wasn't using it correctly obviously. Thanks mate! Danny
  2. Have tried that Robert and i can't get that to work either. Any other ideas? Looking at my code am i going about this the wrong way, should i be using some sort of count? Thanks a lot!
  3. Wont that do it for every row though, rather than just the last one? Thanks
  4. Hi guys Had some great help from here before so thought id try my luck again. Basically i have an array query that works fine, but the echo is going into a piece of Javascript, its basically telling the Java what image paths to use for a Slideshow, each of these needs to be seperated by a comma. Accept for the last one in the array needs to have the comma removed. I can remove the last comma for each row no problem but thats where the problem lies. I only want to remove it from the last row in the array. Any ideas? My code is as follows: <?php $query2 = mysql_query("SELECT * FROM homeimages ORDER by Filename ASC") or die(mysql_error()); while ($row2=mysql_fetch_array($query2)){ $string = "['http://www.benbrownphotography.co.uk/images/home/upload/".$row2['Filename']."'],"; $output = substr_replace($string,"",-1); echo "$output"; } ?> This is fine for if there is only one row in the database but when you add more it is obviously removing the comma from every row. How can i remove it only from the last row in the array? Thanks a lot in advance! Danny
  5. Hi Guys Here goes, i've no idea where to start with this, and i know this place has sorted me out before with all my php needs Im only used to connecting php with MySQL however im now trying to connect to a Microsoft Access .mdb database that i have on my web server and have no idea how. Ive tried lots of combinations and have had no luck. I understand that there is odbc and DSN-Less connections but which one do i use. Also if ODBC how on earth do i go about setting an ODBC connection up on my web server, do i get my hosting company to do it for me?? If possible i would like to by-pass the odbc connection and connect to the db in a different way. Just for a little extra information i have the database file called hope.mdb inside a subfolder on my domain called db. Can anyone please help me?? Thanks alot in advance for any help at all. Danny
  6. Hi all, Ive had some good answers here in the past so thought id stop by again. I'm wondering if its possible to set up an announcements page on a website that can receive emails. To the effect that the subject of the email becomes the Announcement title and the text of the email becomes the body of the announcement? Not sure how to go about this or whether its even feasible, but any help or ideas are greatly appretiated. Thanks alot in advance Danny
  7. Fixed!! Brilliant!! Thanks so much, just needed that push. You guys are great on here! Really appretiate that thx mate. Dan
  8. Ok what ive done is created a page called hashtest.php and made the login form action to that page: the page contains: <?php function hash_pass($pass){ $salt="blabla"; return md5($pass.$salt); } echo $appPassword = hash_pass($_POST["loginpassword"]);?> This echos: 75f3b2ada058ffeae1fbb01a14181d40 Yet in the database it is only: 75f3b2ada058ffeae1fb Now ive had a brain wave, is this all because ive limited the password field in the database to 20 letters!! lol?
  9. Ok, ill try that, sorry to sound dumb, but how exactly should i execute this: echo $appPassword = hash_pass($_POST["loginpassword"]); ?? Just on any random page? Thanks Dan
  10. Right ive tried all sorts, heres all the sections of code i have: The page that inserts the admin username and password into the database: <?php include ('connection.php') ?> <?php function hash_pass($pass){ $salt="blabla"; //must be the same as all your other files return md5($pass.$salt); } $user = "dan"; $pass = "mypass"; $pass = hash_pass($pass); $query = "INSERT INTO `admin`(`username`,`password`) VALUES ('{$user}','{$pass}')"; $result = mysql_query ($query, $connection); ?> Login Action Page: <?php include ('connection.php') ?> <?php session_start(); error_reporting(E_ALL); function hash_pass($pass){ $salt="blabla"; return md5($pass.$salt); } $appUsername = $_POST["loginusername"]; $appPassword = hash_pass($_POST["loginpassword"]); $query = "SELECT * FROM admin WHERE username='$appUsername' AND password='$appPassword'"; $result = mysql_query ($query, $connection); if (mysql_num_rows($result) > 0) { $_SESSION["authenticatedUser"] = $appUsername; header("Location: loggedon.php"); } else { $_SESSION["message"] = "Unable To Login As $appUsername"; header("Location: admin.php"); } ?> The admin logged on page: <?php session_start(); if (!isset($_SESSION["authenticatedUser"])) { $_SESSION["message"] = "Please Login As Admin"; header("Location: index.php"); } else { ?> CONTENT <?php } ?> Thats what ive got, so then when i try to login with the following: Username: dan Password: mypass It doesn't accept it and spits out the message "*Unable To Login As dan" as i set it to if the username and password didn't match that in the database. HELP PLEASE!! 2 Beers for the person that can fix this lol Thanks alot Dan
  11. Right, ive just made random page with the following: <?php include ('connection.php') ?> <?php function hash_pass($pass){ $salt="blabla"; //must be the same as all your other files return md5($pass.$salt); } $user = "dan"; $pass = "mypass"; $pass = hash_pass($pass); $query = "INSERT INTO `admin`(`username`,`password`) VALUES ('{$user}','{$pass}')"; $result = mysql_query ($query, $connection); ?> So that executes fine and inserts. Now i try to login with the username: dan and the password: mypass and it doesn't allow. Is there something else im doing wrong here? Thanks Dan
  12. Thats brilliant thanks alot both of you, specially Scott, hehe. Ill give it a try now, however just curious, what did u mean by: $salt="blabla"; //must be the same as all your other files Thanks Dan
  13. Right, i kind of get you. I changed my code to now: <?php include ('connection.php') ?> <?php session_start(); error_reporting(E_ALL); function hash_pass($pass){ $salt="blabla"; return md5($pass.$salt); } $appUsername = $_POST["loginusername"]; $appPassword = hash_pass($_POST["loginpassword"]); $query = "SELECT * FROM admin WHERE username='$appUsername' AND password='$appPassword'"; $result = mysql_query ($query, $connection); if (mysql_num_rows($result) > 0) { $_SESSION["authenticatedUser"] = $appUsername; header("Location: loggedon.php"); } else { $_SESSION["message"] = "Unable To Login As $appUsername"; header("Location: admin.php"); } ?> But this now makes the password incorrect when i try to login. Remember im using a predefined password in the database. theres no registering involved so im not first inserting a password to the database then trying to login with those details. Im sorry im not great at understanding this... You get what i mean? Dan
  14. Hi guys, Ive been helped here before with success so thought id return and get your expertise once more, Ok so im new(ish) to php and know how to make simple logins but with no security. Im trying my best to learn Md5 and Salting but having no luck. Heres my code at the moment for my login script: <?php include ('connection.php') ?> <?php session_start(); error_reporting(E_ALL); $appUsername = $_POST["loginusername"]; $appPassword = $_POST["loginpassword"]; $query = "SELECT * FROM admin WHERE username='$appUsername' AND password='$appPassword'"; $result = mysql_query ($query, $connection); if (mysql_num_rows($result) > 0) { $_SESSION["authenticatedUser"] = $appUsername; header("Location: loggedon.php"); } else { $_SESSION["message"] = "Unable To Login As $appUsername"; header("Location: admin.php"); } ?> Then this is the script on thats currently setting the session on the admin page: <?php session_start(); if (!isset($_SESSION["authenticatedUser"])) { $_SESSION["message"] = "Please Login As Admin"; header("Location: index.php"); } else { ?> This works fine and simply compares the username and pass to that i have predefined in a database. I want it pre defined as the its an admin section, not a user area for multiple users so theres no registering involved. How do i go about making this secure?? Thanks alot in advance. Dan
  15. Ok, all ive just done is switched the name and id of the button to "addResult" and now its working perfectly. I cant believe i was been so dumb as to not see that. Guess its just really good to have a fresh pair of eyes look at your code to pick things out. Thank you so very much PFMaBiSmAd Danny
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.