Northern Flame
Members-
Posts
816 -
Joined
-
Last visited
Never
About Northern Flame
- Birthday 03/08/1991
Contact Methods
-
Website URL
http://www.northernflame.com
Profile Information
-
Gender
Male
Northern Flame's Achievements
Advanced Member (4/5)
0
Reputation
-
heres one problem i found, if($_SESSION['loggedin'] == 1) { header('Location: home'); } $_SESSION['loggedin'] is not even set yet so its going to default to NULL and later on in the code it is set to 1, that is why it gives you an error message first and then lets you log in....try this: <?php session_start(); //This code runs if the form has been submitted if (isset($_POST['submit'])) { include("includes/dbconnect.php"); // Define $username and $password $username= $_POST['username']; $password= md5($_POST['password']); // To protect MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Retrieve username and password $sql="SELECT * FROM users WHERE username = '$username' AND password = '$password'"; $result = mysql_query($sql); // Mysql_num_row is counting table row $count = mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count == 1){ // retrieve userid from database $sql = "SELECT id FROM users WHERE username = '$username' AND password = '$password'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $userid = $row["id"]; } // update lastlogin $llsql = "UPDATE users SET lastlogin = now() WHERE id = '$userid' AND username = '$username'"; $llresult = mysql_query($llsql); $_SESSION['loggedin'] = '1'; $_SESSION['userid'] = $userid; $_SESSION['username'] = $username; header("Location: home"); unset($_POST['username']); }else { $message = '<div class=red><b>An error has occured.</b> Please check that you are using a valid username/password combination.</div>'; } if($_SESSION['pleaselogin'] == 1) { $message = '<div class=red><b>An error has occured.</b> You must be logged in to view this page. Please login below.</div>'; $_SESSION['pleaselogin'] = '0'; } if($_SESSION['loggedin'] == 1) { header('Location: home'); } } include ("includes/nologin.php"); include ("includes/header.php"); ?> <img src="i/titles/login.png"><br> Please login to your account to participate in our plot, <i>'the Mutated Moach'</i>. If you do not have an account and would like to participate, feel free to <a href="register">create</a> one.<br> <div class="regvalidate"><?php print $message; ?></div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <center><div class="logtable logfont"><table><br> <div style="text-align:left;">Username:</div> <input name="username" type="text" value="<?php echo $_POST['username'];?>" class="regbox"><br><br> <div style="text-align:left;">Password:</div> <input name="password" type="password" class="regbox"><br> <input type="submit" name="submit" class="regsend" value="Login" style="margin: 25px 35px;"> </table></div> </form></center> <?php include ("includes/footer.php"); ?>
-
post the script that processes everything because its going to be hard to help you by only looking at the login form ***never mind for some reason it didnt let me scroll up on your code before but now i see it, ill take a look at it right now
-
yea i probably should have mentioned that haha. well i do enjoy doing server side coding that is why i mentioned asp.net i know i would probably have to go to school for that since i cant find any good tutorials for that online. i guess what i was wondering was what which would benefit me more, which language is there a greater need for out in the job market. I do know that a asp.net programmer would make a lot more than a php programmer would make, but are languages like C & C++ in greater demand?
-
i used 2 be really active on this website but about a year ago i joined the army, lately i have been thinking about my future after the army and thought about going to college and studying some programming languages, but my only problem is that im not sure which language would help me out the most career wise. I am already proficient in HTML, CSS, Javascript, and PHP/AJAX. Im thinking about studying languages like C & C++ or maybe even asp.net or pearl. any ideas as to which would benefit me the most?
-
Automatic Date inserted in Forum
Northern Flame replied to smokenwhispers's topic in PHP Coding Help
oh yea good point, i totally forgot about the time function in SQL, sorry i havnt worked with PHP in about a year so im still trying to refresh my mind -
Automatic Date inserted in Forum
Northern Flame replied to smokenwhispers's topic in PHP Coding Help
<?php echo date("m/d/y") . ' ' . date("h:i a"); ?> -
[SOLVED] No Errors, but It Still Doesn't Work :(
Northern Flame replied to jj20051's topic in PHP Coding Help
you can give this a try: $result = mysql_query("SELECT SUM(`views`) FROM `video` WHERE `username` = '$id'") or die(mysql_error()); if that doesnt work, display the exact setup of your table -
[SOLVED] No Errors, but It Still Doesn't Work :(
Northern Flame replied to jj20051's topic in PHP Coding Help
what number is exactly in the column views -
I know how to make search scripts in PHP, but can someone help me with making a script that will search for certain database entries that are either 5 10 or 15 miles from a zip code? Im guessing im going to have to have a huge list of zip codes in a database. hopefully i can find something on google with a huge list of zip codes, but if i end up getting a big list of zip codes, how can i search the locations in my database that are a certain distance from those zip codes? or do I even need a database full of zip codes? is there an easier way? if someone can help me out with this or show me a tutorial on this I would greatly appreciate it!
-
How can I make the following function return false: <?php function equalValues($one, $two){ if($one == $two){ return true; } else{ return false; } } if(equalValues("test", "TEST")){ echo "same"; } else{ echo "different"; } ?>
-
[SOLVED] Social Networking Site Friends List Help
Northern Flame replied to Northern Flame's topic in PHP Coding Help
wow thanks, that whole while statement in the middle of the sql really helped! I would have never thought of that! thanks! -
well $sqlr = "SELECT userid FROM jos_session"; will grab all the ids in the table jos_session are you sure thats what you want?
-
I am developing a social networking site and i am finishing up the user profiles. I am currently working on the friends list of the user, but I am having trouble finding a way to have the friends table and on grabbing the data. Currently the table is like this: id friends sent pending id - the id of the user friends - list of ids of users on friends list, ex: 1,34,65,32,11 sent - list of ids of users that current user has sent friend requests to pending - list of ids of users that have requested this user as a friend the problem I am having is with grabbing the information of each friend on the friends list when displaying the current users friends. The page will have pagination, it will only display about 20 users per page. I am wondering if I should do something like this: <?php $q = mysql_query("SELECT `friends` FROM `friends` WHERE `id` = '$id'")or die(mysql_error()); $f = mysql_fetch_object($q); $array = explode(",", $f->friends); foreach($array as $key => $fid){ $query = mysql_query("SELECT `display`, `img`, `username` FROM `users` WHERE `id` = '$fid'"; $object = mysql_fetch_object($query); echo ''; // here i echo the users info } now, is this the best way to do this? run 20 queries in the foreach() loop or is there a better way? Please help, ive also considered rearranging my table but I cant find anything that will really work out better than this solution.
-
you can just move that chunk of code to the top of where the main html is echoed. if you need more help show us more code so we can see where you will need to move that code to.
-
*bump