Jump to content

solidusjoe

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

solidusjoe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I noted what you said about if($_POST['username'] == "" || $_POST['pass'] == "") and changed the code in my source files. Thank you. Well, I'll be back in about 10 hours to check on the status of this topic, but until then I have to go to work. Thank you again everyone.
  2. If a user logs in, instead of redirecting them to the members page, the page just remains blank. Also , i scrolled through my cookies and it doesn't look like it is setting the cookie either.
  3. Hello! I receieved some wonderful code help last time I was here so I figured this would be the best place to ask for it again! I am having trouble getting my login page and mebers page to work. I believe it has something to do with the way the cookies are set or something because the if(isset($_COOKIE['cookiename'])) area of the code seems to be what is not functioning correctly. Here is my source: user_login.php <?php require_once('mysql_connect.php'); //Checks if there is a login cookie if(isset($_COOKIE['ID'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID']; $pass = $_COOKIE['Pass']; $check = mysql_query("SELECT * FROM opUsers WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: user_panel.php"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $check = mysql_query("SELECT * FROM opUsers WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href="register.php" target="iframe">Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; $uname = $_POST['username']; $pname = $_POST['pass']; setcookie(ID, $uname, $hour); setcookie(Pass, $pname, $hour); //then redirect them to the members area header("Location: user_panel.php"); } } } else { // if they are not logged in ?> <style type="text/css"> <!-- body { background-image: url(images/bgmain.gif); margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } a:link { color: #CCCCCC; } a:visited { color: #999999; } a:hover { color: #CCCCCC; } a:active { color: #CCCCCC; } .style1 {font-size: 12px} .style2 { font-size: 12px; font-weight: bold; } .style4 {font-size: 8px} .style5 {font-size: 10px} --> </style> <form name="form1" method="post" action=""> <table width="190" height="70" border="0" align="top-left"> <tr> <td width="59"><span class="style2">Username:</span></td> <td width="121"><input name="username" type="text" class="style2" size="20"></td> </tr> <tr> <td><span class="style2">Password:</span></td> <td><input name="pass" type="password" class="style2" size="20"></td> </tr> <tr> <td colspan="2"><div align="left"> <input name="submit" type="submit" class="style4" value="Login"> <a href="register.php" target="iframe" class="style1"><span class="style5">Not a member yet? Register here! </span></a></div></td> </tr> </table> </form> <?php } ?> user_panel.php(members area) <?php require_once('mysql_connect.php'); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID'])) { $username = $_COOKIE['ID']; $pass = $_COOKIE['Pass']; $check = mysql_query("SELECT * FROM opUsers WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: user_login.php"); } else //otherwise they are shown the user panel { $check2 = mysql_query("SELECT acctbal FROM opUsers WHERE username = '$username'")or die(mysql_error()); $actbal = mysql_fetch_array($check2); ?> <style type="text/css"> <!-- body { background-image: url(images/bgmain.gif); margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } a:link { color: #CCCCCC; } a:visited { color: #999999; } a:hover { color: #CCCCCC; } a:active { color: #CCCCCC; } --> </style> <table width="190" height="70" border="0" align="top-left"> <tr> <td><div align="center"><strong><? echo $username?></strong></div></td> </tr> <tr> <td><div align="center"><strong>$<? echo $actbal?></strong></div></td> </tr> <tr> <td><div align="center"><a href="controlpanel.php" target="iframe"> Open Control Panel</a> <a href="logout.php"><strong>Logout</strong></a> </div></td> </tr> </table> <? } } } else //if the cookie does not exist, they are taken to the login screen { header("Location: user_login.php"); } ?> I borrowed some of this code(well a majority of it) from a tutorial on About.Com : http://php.about.com/od/finishedphp1/ss/php_login_code.htm I am not very experienced with PHP yet, but each day I get a little better. This is the last major part of my site before I can officially announce it as up and running. So thank you very much in advance for any help I receive. You guys are great. Sincerely, ~Joe
  4. You've definitley have me going in the right direction now. Thank you for your help!
  5. let's try this again, my previous topic went unsolved for some time now. Basically what I am trying to do is create a page that will redirect a user to another page. however this page has to use a variable from the mysql database to know what url to send the person to, and the url of this redirection page has to carry their specific user id number as well as an id number for the site they are being sent to. Broken down, by theory it should work like this: 1. User number 123 clicks on a link to a website on one of my pages, that is supposed to direct them to the site associated with the site id 456. 2. the link would look like mysite.com/out.php?user=123&site=456 3. The out.php page would read in the url associated with id 456 and then redirect the user to that url. I hope someone can help me out because I am very stuck and this is one of the most crucial points of my project. I will also be needing to use a session ID to make sure the user is clicking on links with their own unique user id. Can someone please help me solve this problem? I'm really new to php, but I need to be able to do this. Thank you very much in advance.
  6. Anybody? ???
  7. :-\ Well that looks like it may put the numbers I need in the url however I do need to somehow take numbers from the dbs in order to put them in the url. Here's a little more of an example of what I'm looking for, say someone is going through an index of links, each url has its own unique id number. The user looking at those links, also has a unique id number associated with their user name, so that when they click on a link to say www.phpfreaks.com the url would look like www.mysite.com/out.php?siteid=<sitenumber>&userid=<useridnumber> It's not a matter of just getting numbers in the url, it is a matter of making each url link dynamically different than that another user would use. While the same site would share site id numbers, the user id numbers would be different based on who is going through them. It also needs to redirect them to that specific url. So i need some page code that would run a little like this: <?php conenct to db containing site_id; put that as the site_id part of the url; record the site url associated with that site id in a variable or something; close datatabase; open the db containing user_id; using the username logged in find the users approriate unique user id and put that in the user_id part of the url; close database redirect to the page associated with the site_id used; ?> Many thanks for your help and consideration! I hope this clears things up a bit. I've seen this done on many sites before, but have no clue as to how they did them. Thank you again in advance to anyone who helps. ~Joe
  8. Hi, I'm a php n00b, I just started working with it for the first time this week. I've been scroungin around for some help oin this for a while and I am hoping I have found the right place. I am trying to create a user specific id link using some sort of gateway page (i.e. out.php, gateway.php, yada yada). something like this: www.mysite.com/out.php?siteid=123?userid=456 anyone have any resources or code so I can get through this? for the site id I need ti to read the url it is redirecting to from my database. I'll be back to check this forum tongiht, many thanks in advance for any help you guys give me. ~Joe
×
×
  • 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.