Jump to content

Bavilo

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Bavilo's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello everyone, I'm helping a friend with some scripting. I made a register and login script that takes the raw input and puts it into a database, the password is encrypted in md5, that part works, aswell as the login part but i need to display a unique page for each user. Basically my friend will create the usernames and passwords with the register script, lets say the username is 123 and the password is 321, when i enter 123 in the login box and i successfully login the page should now display information about only the user "123" such as a schedule, of things this user has to do and so on. I was thinking about using something like this. [code] <?     if (isset($_SESSION['s_username'])) {     echo "<b>Welcome</b> ".$_SESSION['s_username']."!"; }   ?> [/code] This will display the name of the username that was entered in the login script, but instead i want it to check what username was entered, (in this case "123") take that username, check if its in the database and use that in the session code above instead of "username". Also, if 123 is logged in, it will not echo [code] <b>Welcome</b> ".$_SESSION['s_username']."!"; [/code] , but other php snippets, codes, html, whatever. Ok just to wrap it up, what i am trying to figure out is how to change the content on a page such as a schedule that will be different for every user that signs on. Hopefully someone can point me to some examples or explain how this could be done. If anything is unclear please let me know, i will try to explain it some more. Thanks Mike
  2. Hello everyone, I have posted before asking to help me with a problem of storing passwords as MD5 hashes in the database instead of plain text. This worked out great, but i have a new problem. When a user registers, the password is hashed and then submitted into the database. When the user logs in, the password he types is getting hashed, and then checked against the checked password in the database, this works great, but i have a forgot your password script that when you enter your email address, it looks for the username and password on the same row of that table and then sends you the information. The user will receive the Hashed password instead of the plain text password because thats how the password was stored when he registered. Is there a way to make it so the password he receives is the plain text password? Here are my scripts Register.php [code] <?php if (isset($_POST["username"])) { $username = $_POST["username"]; $password = md5($_POST["password"]); $cpassword = md5($_POST["cpassword"]); $email = $_POST["email"]; if (empty($username) || empty($password) || empty($cpassword) || empty($email)) { echo "A field was left blank."; }else{ if($password!=$cpassword) { echo "Passwords do not match"; } else { $checkuser = mysql_query("SELECT `username`, `email` FROM `users` WHERE `username` = '$username' OR `email` = '$email'") or die('SQL error: ' . mysql_error()); $user_exists = mysql_num_rows($checkuser); if ($user_exists > 0) { echo "The username or email is already in use"; } else { $query = "INSERT INTO users (`username`, `password`, `email`) VALUES('$username', '$password', '$email')"; mysql_query($query) or die(mysql_error());echo "The user \"$username\" has been successfully registered. You may now login."; } } } } ?> [/code] Login.php [code] <?php if ($_POST['username']) { $username=$_POST['username']; $password= $_POST['password'];         if (empty($username) || empty($password)) { echo "You didn't enter a username and/or password"; }else{ $password = md5($password); $query = mysql_query("SELECT `username`, `password` FROM `users` WHERE `username` = '$username' AND `password` = '$password'") or die(mysql_error()); $row = mysql_fetch_assoc($query); if (!$row)  { echo "The Login you entered is incorrect"; } else { $_SESSION['s_username'] = $row['username']; echo "<meta http-equiv='Refresh' content='0; url=index.php'>"; } } } ?> [/code] Forgot.php [code] if (!mysql_select_db($dbname)) die(mysql_error()); if($_POST['email']) { $email = $_POST['email']; $checkemail = mysql_query("SELECT username,password FROM users WHERE email='$email'"); $row = mysql_fetch_array($checkemail); $numrows = mysql_num_rows($checkemail); if ($numrows!=0) { $name = $row['username']; $password = $row['password']; $subject = "subject here"; $message = "Message here"; mail($email, $subject, $message, "From: \nX-Mailer:PHP/" . phpversion()); echo "<center>Password sent.<br /><br /></center>"; }else{ echo "<center>The supplied address does not exist in our database.<br /><br /></center>"; } } } ?> [/code] Thanks in advance Mike
  3. Ok it works now, the row for the passwords didn't allow enough characters for the hash. Fixed that and shes up and running. One more problem. I have a Forgot Password? script that sends you your username and password from the row of the email you entered. Well, now it sends the hash. Any way i can make it so it sends the actual password instead of the hash? Thanks Mike
  4. Thanks for the great tips! Everything works great except or the login part, it still says that the login is incorrect. I made sure that when i sign up the password is hashed in the table. I guess the login tries to check the actual password instead of the encrytped password? Im not really sure how to fix this. Any further help is appreciated. Btw is used the code you gave me. Here is the site btw, check it out and see for yourself. [a href=\"http://mike.eurodogcrates.com/login.php\" target=\"_blank\"]http://mike.eurodogcrates.com/login.php[/a] Mike
  5. Hello folks, I am making a Register and Login script for my site. It works great but i would rather have the passwords be encrypted using md5. Right now i have figured out how to store the password the user enteres in the registering page into md5 right into the database. Now i want to be able to have the user login, his password that he enters gets encrypted, and then checked with the one on the database. Im not sure how i would go about encrypting the password on the login script. I hope someone can help me out a little. Here are the 2 scripts. Register.php [code] <?php          $dbhost='localhost';           $dbusername='username';          $dbuserpass='password';          $dbname='database name';          mysql_connect ($dbhost, $dbusername, $dbuserpass);          mysql_select_db($dbname) or die("Cannot select database");          if (isset($_POST["username"])) {          $username = $_POST["username"];          $password = md5($_POST["password"]); //here the password was hashed and then submitted          $cpassword = md5($_POST["cpassword"]); //here the password was hashed and then submitted          $email = $_POST["email"];          if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {          echo "A field was left blank.";          }else{          if($password!=$cpassword) {          echo "Passwords do not match";          }else{          $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");          $username_exist = mysql_num_rows($checkuser);          $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");          $email_exist = mysql_num_rows($checkemail);          if ($email_exist>0|$username_exist>0) {          echo "The username or email is already in use";          }else{          $query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')";          mysql_query($query) or die(mysql_error());          echo "The user \"$username\" has been successfully registered. You may now login.";          }          }          }          }          ?> [/code] Login.php [code] <?php          $dbhost='localhost';          $dbusername='username;          $dbuserpass='password';          $dbname='username database';          mysql_connect ($dbhost, $dbusername, $dbuserpass);          mysql_select_db($dbname) or die('Cannot select database');          if ($_POST['username']) {          $username=$_POST['username'];          $password=$_POST['password'];          if ($password==NULL) {          echo "You didn't enter a password";          }else{          $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());          $data = mysql_fetch_array($query);          if($data['password'] != $password) {          echo "The Login you entered is incorrect";          }else{          $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());          $row = mysql_fetch_array($query);          $_SESSION["s_username"] = $row['username'];          echo "<meta http-equiv='Refresh' content='0; url=loggedin.php'>";}          }          }          ?> [/code] Again, not sure how i would encrypt the password on the login script and have it succesfully check out on this line so it gets submitted "data = mysql_fetch_array($query); if($data['password'] != $password) {" Thanks in advance Mike
  6. Bavilo

    Help with CSS!

    Hello everyone, I have recently started to work on a website i have to make for school. I am having problems with the allignment of the different divs. For example, i have a header which should float in the top right, followed by a tab menu in its own wrapper div 20 pixels below the header, then a navigation menu floating on the left below the tab menu, and a content box floating on the right next to the navigation menu. Well it sounds simple, but its not coming out the way it should, i have to clear: both; the tab menu for it to even show up under the header, which i should have to do. Well here is a link to the page im working on. I hope someone can look over my code and tell me what i could change to make it work better. Also, im trying to keep the page resolution friendly, not sure how i would do that. Again, any help is much appreciated. Here is the link [a href=\"http://mike.eurodogcrates.net/test/\" target=\"_blank\"]http://mike.eurodogcrates.net/test/[/a] btw, i left the borders on so you can see whats going on. Seems the main container wont hold anything under the tab menu, dont know whats going on there aswell
  7. Ok this one should be relativly easy for you hardcore coders out there...I was browsing on Wiki one day and decided that my page needs those slick Tabs at the top aswell... I looked at quiet a few tutorials examples you name it. I got the Tabs looking nice and everything but i till have a slight problem. The "active" tab, the tab that is standing out from the other when its clicked. Annoyed, confused, and devestated, i spent several hours looking at more examples and this is what i found out. When ever you click a link, MAGICALLY the tab has a ID tag in the hyperlink. So instead of a href="blah.html"> it now has a href="blah.html" id="selected"> or the similar. This would be pretty much common sense, the link now has the propertied given by the style sheet under #selected. Only problem is...how in the HELL do you get that ID tag there in the first place? i mean all these tutorials are great, but they dont show me how they get this Tag there. I've even thought about using PHP, such as this (im not a php coder, so this WILL be wrong) a href="blah.html" value="selected"> then when you click the link, it will submit the value, such as a POST field in php, out it into a string, and then in my body id="$string"> thus giving me the effect. Is this possible? if so, how? I would much rather go the css route though. I hope ANYBODY out there could help me :( Thanks in advance Mike
  8. Hello, I was thinking about adding a search field on my site. A field where i just enter some text, click search, and then a new page pops up with the google results of that query. What i need to know is how to append the following: site:http://mysite.com so it actually calls for "blah blah site:http://mysite.com" Can i do this using php? Thanks Mike
  9. Ok, I am really frustrated right now...This has been going on for several weeks now and i just cannot find an answer. I have one index.php where i have the following code [code] <?         $val = $_GET['id'];         $val .= ".php";         $dirty = array("..");         $clean = array("");         $val = str_replace($dirty, $clean, $val);         if (isset($_GET['id'])) {         if (file_exists($val)) {         include "$val";         }           else {                 include "id/404.php";                }        }           else {                 include "id/start.php";        }     ?> [/code] I use this to navigate from page to page without having to make a complete new page for everything. So this basically just includes another page with the php extension into my main div. This works great for pages that do nothing but hold content. But it will not work if i try to link to a gallery or slideshow, or whatever, that has to include other pages. Once i include for example gallery.php, the gallery.php is now part of my index.php in the main div. It has no way of including all the other pages as its in the wrong directory. And i can't just go into the gallery.php and change every single link because it doesn't seem to work in this format. index.php?id=id/gallery/ I dont know what to do. How does everybody else pull this off?? Thanks in advance Mike
  10. Schweeeet it works great. Thanks!
  11. [!--quoteo(post=354097:date=Mar 11 2006, 10:20 PM:name=Prismatic)--][div class=\'quotetop\']QUOTE(Prismatic @ Mar 11 2006, 10:20 PM) [snapback]354097[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]<?php if (!is_numeric($_POST['field']){     echo "Not a number!"; } else{     echo "Number!"; } ?>[/code] [/quote] Thanks i will try that in a bit
  12. Hello, I have a form which submits info and emails it to me. I have a few fields that should only take numerical values, such as the zip code field, and phone number field. Is there anyway i can validate those fields and give an error if anything besides numbers have been entered? Thanks in advance
×
×
  • 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.