Jump to content

cyimking

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cyimking's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok that solves that problem. Now what is not happening, is that its not logging in the member. Although all my information are correct..
  2. Notice: Undefined variable: er in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\empora\login.php on line 55 on the login.php one... Fatal error: Call to undefined method Process::md5() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\empora\scripts\test.php on line 49 on the test.php one.
  3. Well that is where its going. The name is under test.php because im testing it, which runs all the code. So process.php is currently empty, i just used that name. @creata.physics - Where would i put that code at? @Niixie - What will the 0 or 1 do? I set it so if $check_login == 0, redirect to the index.php page, which should have the user logged in. BUT this is not what is happening. Regardless of what i do, it is going to the test.php (process.php, same thing) in a blank page. The only code that is working, is if a user goes there by accident, then it redirect him page to the index.php page.
  4. Im working on a simple login script. I had it working correctly the first time, but i was told that if i made the code into a function then it will benefit me in the long term... So i tried to do just that, and regardless of what happens it do not work. When the user click the submit button , he is going into a process file, which will process his login information and if correct, then he will be directed back to the home screen. But what really happens is that, the user is redirected to the process.php file with blank data... I know there an error somewhere in here. process.php <?php include_once "../config.php"; include_once "../login.php"; //Process all the information so that everything is nice and fine! class Process { var $username; var $password; var $id; function Process() { if(isset($_POST['sublogin'])) { $this->prologin(); } else if(isset($_POST['sublogout'])) { $this->prologout(); } else header("location: ../index.php"); } function prologin() { $check_login = $this->login($_POST['username'],$_POST['password']); if($check_login) { header("location: ../index.php"); } else $er = "Incorrect Login Information!"; } function login($username,$password) { $this->password = $this->md5(password); $sql = mysql_query("SELECT * FROM members WHERE username = '$username' and password = '$password'"); $check_sql = mysql_num_rows($sql); if($check_sql != 1) { $er = "User does not exist."; } else { while($row = mysql_fetch_array($sql)) { $this->id = $row['id']; $_SESSION['id'] = $this->id; $_SESSION['username'] = $this->username; return true; } } } } $process = new Process; ?> login <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/main.css" /> <title>Welcome Back</title> </head> <body> <?php include_once "header.php"; ?> <h1><center>Welcome Back, Please Sign In.</center></h1> <center><?php echo $er; ?></center> <div class ='login'> <div class='login_inside'> <div class='login_header'> Login </div> <table class='login_table'> <form action='scripts/test.php' method='POST'> <tr> <td>Username: </td> <td><input type='text' name='username' /></td> </tr> <tr> <td>Password: </td> <td><input type='password' name='password' /></td> </tr> <tr> <td></td> <td><input type='submit' name='sublogin' value='login' /></td> </tr> </form> </table> </div> </div> </body> </html>
  5. Im back once more, learning php, and i realize that i have to fully learn functions and classes before i begin working on my project. So to learn i created 2 sample scripts. One is suppose to be a mini table, that ask the user to input a number. The form will go to main.php which will run a function that decides whether the number is blah, not cool, or cool number and return it. But the problem is, that is not what is happening. A cool number is > 10, a not cool number is < 7 , and the blah number is 7-10. What is happening is that it is ONLY returning a not cool number. index.php <?php include "main.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Testing!</title> </head> <body> <table> <form action='main.php' method='post' /> <tr> <td>Please Input a number!</td> <td><input type='text' name='number' /></td> <td><input type='submit' name'submit' value='next' /></td></tr> </form> </table> </body> </html> main.php <?php class test { var $number; function process() { if(isset($_POST['submit'])) $this->sample(); } function sample($number) { $number = $_POST['number']; if($this->number > 10) return "Number is a cool one!"; else if($this->number < 7) return "Not cool bro"; else return "blah"; } } $type = new test; echo $type->sample(); echo $type->number; ?>
  6. Thanks ! It works fine now.
  7. Ok, so im working on a site, and i ran into an error. Its seems to be that when i log in onto a sample account, it goes to the index.php page. Then , in the header, it's a link to go to the user's profile page. The link to their profile page is localhost/mysite/members/profile.php?id='.$id.' And the $id is set to the Session that is currently into play. So if the user id is #1, then in the link will be localhost/mysite/members/profile.php?id=1[/code] BUT if i type in , lets say 2 in the browser, then it should display the second user, but instead it still display the first user. Even if i type in 10000000000000000, it will still go back to the first user. Profile.... <?php include_once "../config.php" ; // MUST include. //Check To make sure a valid session is stored! If not, die message will occur. if (isset($_SESSION['id'])) { // Set up the ID variable. It should be equal to 1. $id = $_SESSION ['id']; //Get variables to make sure the ID exist AND make sure that the user is using the correct ID. $sql = mysql_query("SELECT * FROM members WHERE id = '$id' LIMIT 1"); $check = mysql_num_rows($sql); if ($check > 1) { echo "No one matches that id number!"; exit(); } //Check to make sure that the ID matches another ID in the database if($check == 1) { while($row = mysql_fetch_array($sql)) { //Set up variables from the database $username = $row['username']; $email = $row['email']; $join_date = strftime("%b %d, %Y", strtotime($row['join_date'])); $bio = $row['bio']; $check_pic = "../members/members/$id/pic1.jpg"; $default_pic = "../members/members/0/pic1.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; } else { $user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; } //Check to see what type of member the user is. if ($row['account_type'] == a) { //A users are Admin. $account_type = "Administrator"; } else if ($row['account_type'] == b) { //B users are Moderators $account_type = "Moderator"; } else //Regular Members $account_type = "Regular Member"; } // End while loop! } else die ("Must be logged in to view this page!"); } else die(); ?> Heade include_once"config.php"; //Include the config.php which connects to the server and database $toplinks = ""; if(isset($_SESSION['id'])) { //Setting the local variables based on the login details $id = $_SESSION ['id']; $username = $_SESSION['username']; $toplinks = '<a href ="/empora/members/profile.php?id='.$id.'">'.$username.'</a> <a href="members_account.php"> Account </a> <a href="/empora/logout.php">Log Out</a>'; } else { $toplinks = '<a href="registration.php"> Join Now </a> <a href="login.php">Login Now</a>'; } ?> PS. I am slowly working into making all of this into functions, but this error have to be address first.
  8. Thank you. Its working. I just have to make it look durable. But thanks again.
  9. Hello, I just reach the ultimate high in frustration because i can not display all the data from my database in a table using php. Im trying to display all the members from my database (id, username, email and account type) in my admin cp, and what is happening is that i am displaying all my data in one td. (Ex, in the <td></td>, it will display all the usernames at once, rather than separating them). <?php include_once "../config.php"; include_once "admin_check.php"; $get_members = mysql_query("SELECT * FROM members ORDER BY id"); while ($row = mysql_fetch_array($get_members)) { $id .= $row['id']; $username .= $row['username']; $account_type .= $row['account_type']; $email .= $row['email']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome Admin!</title> </head> <body> <h1>Welcome admin! <a href='../index.php'> Click here to go back! </a></h1> <table cellspacing="5" cellpadding="5" style="border: black thin solid" align="center"> <tr> <td>ID</td> <td>Username</td> <td>Email</td> <td>Account Type</td> </tr> <tr> <td><?php echo $id;?></td> <td><?php echo $username;?></td> <td><?php echo $email;?></td> <td><?php echo $account_type;?></td> </tr> </table> </body> </html> Now i tried making the table in the while loop, but i am also having the same problem. Please help.
  10. I been researching on how to properly include a file (config.php file), and i was wondering which is better? define(DOC_ROOT,dirname(__FILE__)); include(DOC_ROOT.'/config.php'); or... include_once "config.php";
  11. I fixed the issue, my MySQL was in strict mode i guess... I had to change it doing this. sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  12. Thanks for the reply "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" in phpmyadmin.
  13. Mysql Version : 5.5 Code for my registration (the main part, where error is located) $sql = mysql_query("INSERT INTO members (username, email , password, join_date) VALUES ('$username','$email','$protect_password', now())") or die (mysql_error()); Error Im receiving: "Field 'bio' doesn't have a default value". Again: 'bio' is a text type field, which can not have a default value.
  14. Ok, so im not sure if this been answered or address yet, but when i go to register a user into my database, i get an error about my bio not having a default value? When the user register they only have to enter their email, username, and password. My "bio" is a text type, and when i go to the users that i already have register and edit the bio part (in a edit_profile.php file, using the update function), it works fine. I also notice that this only occurs when the selected columns are text/blog types.
×
×
  • 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.