Jump to content

florida_guy99

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by florida_guy99

  1. Thank you What would be a good place to download some lessons or some material to learn ?
  2. Hi Everyone, I am not a programmer, I actually have very little experience with PHP, but I have a question. I am willing to learn, but I'd like to know how difficult it would be to write a code that would do the following: A real estate website. First, I'd like to have a page password protected that will allow me and other agents to input information (size, type, locations, photos, flyers, siteplans, etc) about a certain property, that info gets sent into a database. From the main page on the website, guests can do any of the following: SEE ALL PROPERTIES - a page is generated with all properties that are on the database, they can click on the name of each property and be sent to a property detail page. OR I'd liek to have a search engine where they will choose what kind of property they are looking for, they can search for instance, only commercial properties, or only properties in Orlando, FL, etc.. Would that be too difficult to make ? Where should I begin ? I found some scripts online but they are more for people wanting to create a commercial website to allow others to register and pay to place listings, which is not the case here. Any help will be greatly appreciated. Thanks
  3. I have been out of the country but I just tried all the above suggestions and now when wrong login info is entered, it just goes right back to login.php and username and password fields cleared. I guess that works as well... Thanks guys !
  4. Did not. :-\ It shows a blank page whether I put a username or not, same with password and same when I put any name and password - it just sits on a blank login.php page.
  5. You are guys are awesome !!!! ;D ;D It is working... I have just one quick question, how come when I put a wrong password, or wrong username, or nothing, instead of showing an error, it shows a totaly blank login.php ?
  6. Thanks chocopi. I've been messing with this for days now, I almost know the codes all by heart...and I am so close to giving up, because I cant seem to be able to make it work. Now, it sends me to the right page, but it just shows a blank index.php... is there any special coding for when you mix php codes and html on the same page ? Here is the current code. login.php <?php error_reporting(E_ALL); require_once("page_header.php"); if($_POST) { $username = mysql_real_escape_string($_POST['username']); // get the posted username and set to variable $password = mysql_real_escape_string($_POST['password']); // get the posted password and set to variable $query = mysql_query("SELECT id,unique_code FROM login_pib WHERE username='$username' && password='$password'") or die(mysql_error()); // check to see if username and password match database $num_rows = mysql_num_rows($query) or die(mysql_error()); // count the number of rows to check if no rows have been returned if($num_rows != 0) // if the database finds nothing don't login { $row = mysql_fetch_assoc($query) or die(mysql_error()); // get data from database $id = $row['id']; // set the user id from the database to a variable $code = $row['unique_code']; // set the code from the database to a variable session_start(); // start the sesssion so we can check later to see if they are logged in as the right user $_SESSION['id'] = $id; // set the id to the session $_SESSION['username'] = $username; // set the username to the session $_SESSION['password'] = $password; // set the password to the sesison $_SESSION['code'] = $code; // set the unique code to the session $location = "users/{$username}/index.php"; // create the location for the user header("Location: $location"); // redirect the user to their folder } else { echo "Your login was incorrect."; // if no match found echo error message } } ?> <form name="form" method="post" action="<?php echo $PHP_SELF; ?>"> <input type="text" name="username" /><br /> <input type="password" name="password" /><br /> <input type="submit" name="submit" /> </form> index.php <?php error_reporting(E_ALL); // show any errors, if any require_once("/homepages/35/d88707459/htdocs/pibland/page_header.php"); session_start(); // start the session $page_username = "john"; // set the username for the file eg john for users/john/index.php $id = $_SESSION['id']; // set the session id to a variable $username = $_SESSION['username']; // set the session username to a variable $password = $_SESSION['password']; // set the session password to a variable $code = $_SESSION['code']; // set the session code to a variable $query = mysql_query("SELECT username FROM login_pib WHERE id='$' && username='$username' && password='$password' && unique_code='$code'") or die(mysql_error()); $row = mysql_fetch_assoc($query) or die(mysql_error()); $user = $row['username']; if($user != $page_username) { die("You are not allowed to view this page!"); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> </HEAD> <BODY> <strong>Hello !</strong> </BODY></HTML> page_header.php <?php $db_host = "xxxxxxxxxxxxx"; $db_username = "xxxxxxxxxxxxxxx"; $db_password = "xxxxxxxxxxxxx"; $db_database = "xxxxxxxxxxxxxx"; $db_con = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_database) or die(mysql_error()); ?>
  7. ok It is taking me to the right page now but the whole page is just blank... :'( :'( :'( :'(
  8. well i got it, now it sends me to the right place and says: "You are not allowed to view this page!" here is my code from index.php <?php error_reporting(E_ALL); // show any errors, if any require_once("/homepages/35/d88707459/htdocs/pibland/page_header.php"); session_start(); // start the session $page_username = "username"; // set the username for the file eg john for users/john/index.php $id = $_SESSION['id']; // set the session id to a variable $username = $_SESSION['username']; // set the session username to a variable $password = $_SESSION['password']; // set the session password to a variable $code = $_SESSION['code']; // set the session code to a variable $query = mysql_query("SELECT username FROM login_pib WHERE id='$id' && username='$username' && password='$password' && unique_code='$code'") or die(mysql_error()); $row = mysql_fetch_assoc($query) or die(mysql_error()); $user = $row['username']; if($user != $page_username) { die("You are not allowed to view this page!"); } ?> my question is, am I supposed to change any of this code and add the username, password, ID and unique code ? cuz somewhre it is not recognizing me as right person allowed to see that page.
  9. Did that and same error... it sends me to users//login.php
  10. mtheve was right, but there were some other errors elsewhere, so after getting literally tens of these error messages, I played with it enough that I got everything to ALMOST work perfectly. But, now I am getting an error, that looks so easy to fix but I cant figure out where the error is. So the login page is working, but instead of sending me to /users/username/index.php, it is sending me to /users//index.php (404 error), so somewhere it is missing the function that sends me to the right folder and then to the index.php in that folder. You guys have been extremely helpful and I've learned a lot (well - not a lot, but I didnt know anything about PHP so I learned some)... so I ask again, HELP !!!
  11. yeah... it is crazy. I wonder why it is not working... ???
  12. ok I accidentally deleted it when pasting the code on here... but it is there.
  13. Thank you. ok, this is the login.php <?php error_reporting(E_ALL); require_once("page_header.php"); if($_POST) { $username = mysql_real_escape_string($_POST['username']); // get the posted username and set to variable $password = mysql_real_escape_string($_POST['password']); // get the posted password and set to variable $query = mysql_query("SELECT id,unique_code FORM tablename WHERE username='$username' && password='$password'") or die(mysql_error()); // check to see if username and password match database $num_rows = mysql_num_rows($query) or die(mysql_error()); // count the number of rows to check if no rows have been returned if($num_rows != 0) // if the database finds nothing don't login { $row = mysql_fetch_assoc($query) or die(mysql_error()); // get data from database $id = $row['id']; // set the user id from the database to a variable $code = $row['unique_code']; // set the code from the database to a variable session_start(); // start the sesssion so we can check later to see if they are logged in as the right user $_SESSION['id'] = $id; // set the id to the session $_SESSION['username'] = $username; // set the username to the session $_SESSION['password'] = $password; // set the password to the sesison $_SESSION['code'] = $code; // set the unique code to the session $location = "users/{$username}/index.php"; // create the location for the user header("Location: $location"); // redirect the user to their folder } else { echo "Your login was incorrect."; // if no match found echo error message } } ?> <form name="form" method="post" action="<?php echo $PHP_SELF; ?>"> <input type="text" name="username" /><br /> <input type="password" name="password" /><br /> <input type="submit" name="submit" /> </form> This os page_header.php <?php $db_host = "XXXXXXXXXX"; $db_username = "XXXXXXXX"; $db_password = "XXXXXXXX"; $db_database = "XXXXXXXXX"; $db_con = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_database) or die(mysql_error()); ?> and this is the individual user page <?php error_reporting(E_ALL); // show any errors, if any require_once("page_header.php"); session_start(); // start the session $page_username = "XXXXXX"; // set the username for the file eg john for users/john/index.php $id = $_SESSION['1']; // set the session id to a variable $username = $_SESSION['XXXXX']; // set the session username to a variable $password = $_SESSION['XXXXX]; // set the session password to a variable $code = $_SESSION['0001']; // set the session code to a variable $query = mysql_query("SELECT username FROM tablename WHERE id='$id' && username='$username' && password='$password' && unique_code='$code'") or die(mysql_error()); $row = mysql_fetch_assoc($query) or die(mysql_error()); $user = $row['username']; if($user != $page_username) { die("You are not allowed to view this page!"); } ?> What do you say ?
  14. Not sure where I change that, but the only place I found a line similar to that was on the "individual user" page (index.php) and it only has one '
  15. I am very unsure of what to do now... So I created the table (hopefully it's right), the page_header.php, the login.php and the individual user pages... and now I am getting this error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'tablename WHERE username='xxx' && password='xxx' at
  16. ok never mind I found the error... It was missing a ")"
  17. duhh I am so stupid. See I am so new to this thing... lol Anyway, it is line 8 on the page_header.php file... which is: mysql_select_db($db_database) or die(mysql_error();
  18. Hi Guys, Thanks BlueSkyIS, that was the problem... Now I am getting: Parse error: parse error, unexpected ';' in /homepages/35/d88707459/htdocs/pibland/page_header.php on line 8 This is line 8: $query = mysql_query("SELECT id,unique_code FORM tablename WHERE username='$username' && password='$password'") or die(mysql_error()); // check to see if username and password match database I bet it is something with the table that I created, I read all the documentation provided by the host (1and1.com) but maybe I slipped somewhere... Thanks a lot..
  19. Here we go. I am going to check out http://www.w3schools.com/ Thank you so much !! <?php error_reporting(E_ALL); require_once("page_header.php"); if($_POST) { $username = mysql_real_escape_string($_POST['username']); // get the posted username and set to variable $password = mysql_real_escape_string$_POST['password']); // get the posted password and set to variable $query = mysql_query("SELECT id,unique_code FORM tablename WHERE username='$username' && password='$password'") or die(mysql_error()); // check to see if username and password match database $num_rows = mysql_num_rows($query) or die(mysql_error()); // count the number of rows to check if no rows have been returned if($num_rows != 0) // if the database finds nothing don't login { $row = mysql_fetch_assoc($query) or die(mysql_error()); // get data from database $id = $row['id']; // set the user id from the database to a variable $code = $row['unique_code']; // set the code from the database to a variable session_start(); // start the sesssion so we can check later to see if they are logged in as the right user $_SESSION['id'] = $id; // set the id to the session $_SESSION['username'] = $username; // set the username to the session $_SESSION['password'] = $password; // set the password to the sesison $_SESSION['code'] = $code; // set the unique code to the session $location = "users/{$username}/index.php"; // create the location for the user header("Location: $location"); // redirect the user to their folder } else { echo "Your login was incorrect."; // if no match found echo error message } } ?> <form name="form" method="post" action="<?php echo $PHP_SELF; ?>"> <input type="text" name="username" /><br /> <input type="password" name="password" /><br /> <input type="submit" name="submit" /> </form>
  20. ok, sure enough I can't get the whole thing to work. I didnt want to be a pain in the butt here, but I didnt even know how to create a table, so I researched, researched and finally figured it out. I use 1and1.com to host my website, I created a table, created a login.php (where the login form is), created a page_header.php and created one individual folder with one individual page just for testing... So I went on login.php and this is what I get: Parse error: parse error, unexpected T_VARIABLE in /homepages/35/d88707459/htdocs/pibland/login.php on line 7 :(
  21. Thank you guys very very very much !!! I am going to class right now, so I wont have time anymore to day to play with that, but I will tomorrow and I will let you guys know how it worked out. But Thanks a LOT !!!
  22. thank you sooooooo much for your help !! So I will create the folders and subfolders now and then paste your code onto the login page... And where do I set passwords/usernames and the URL where users should to be redirected to once they log in ? Thank you and sorry if I am being too difficult..
  23. By different pages I mean I will manually make individual pages with some flyers and some other information for each individual/specific person. Like I said I am not familiar with PHP at all, so I am not sure where to begin... create a database with the login information and the page where those users should be redirected ? I am so lost !!
×
×
  • 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.