Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. okay i did it again and it worked, took a while for it to ftp over i guess. Anyway thanks mate your a life saver. And i think you're all nice enough to leave my db alone lol.......hoping anyway. On that note can people use those to their advantage? should i be changing the pass?
  2. Undefined variable $row1 where is the query that looks in the db? Also i noticed i included my db details.....but you can just pretend you missed them lol
  3. Im using a query to display a users email address from the database. The problem is when i use this query i get the word email displayed on the screen twice and then their email, but the word email should only be appearing once. Any suggestions? Heres the code: <?php ob_start(); include('header.php'); include('contentholder.php'); // Connects to your Database $db=mysql_connect("sql304.000a.biz", "a000b_4450564", "984497") or die(mysql_error()); mysql_select_db("a000b_4450564_BBT") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users 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: login.php"); } //otherwise they are shown the admin area else { echo '<center>Welcome to your area ' .$username. '</center><br><br>'; $emailresult = mysql_query("SELECT * FROM users"); while($row1 = mysql_fetch_array($emailresult)){ echo '<font size="2"><b>Email:</b></font>','<b>',' ',$row1['email']; echo "<br />","<br />"; } echo "<br><br><a href=logout.php>Logout</a>"; } } } else //if the cookie does not exist, they are taken to the login screen { header("Location: login.php"); } include('footer.php'); ob_flush(); ?>
  4. okay ive done it, i added the ob_flush this to the top and bottom of login.php and it works fine now. Cheers for the advice everyone, im glad to be marking this as solved!
  5. same error: followed your post down to the letter. Is there a way to check wether a user is logged in(which is all i want to do). I want it to check wether they are logged in or not in my heder.php from the code in login.php. Heres login.php again: <?php include('header.php'); include('contentholder.php'); // Connects to your Database mysql_connect("sql304.000a.biz", "a000b_4450564", "984497") or die(mysql_error()); mysql_select_db("a000b_4450564_BBT") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: index.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['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users 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=add.php>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'])or die(mysql_error()); $hour = time() + 3600; setcookie('ID_my_site', $_POST['username'], $hour)or die(mysql_error()); setcookie('Key_my_site', $_POST['pass'], $hour)or die(mysql_error()); //then redirect them to the members area header("Location: index.php")or die(mysql_error()); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } include('footer.php'); ?>
  6. okay i added them things before and after the php in header.php but i still get this error: Here is my code for header.php: <?php error_reporting(E_ALL); ini_set("display_errors", 1); ?> <!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" dir="ltr" lang="en-gb" xml:lang="en-gb"> <head> <title>Blender 101 | Home</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="en-gb" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="resource-type" content="document" /> <meta name="distribution" content="global" /> <meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <link rel="stylesheet" href="stylesheet.css" type="text/css" /> <link rel="stylesheet" href="css/gallery.css" type="text/css" media="screen" charset="utf-8" /> <script src="scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script> <script src="scripts/mootools-1.2-more.js" type="text/javascript"></script> <script src="scripts/jd.gallery.js" type="text/javascript"></script> <script src="scripts/jd.gallery.transitions.js" type="text/javascript"></script> <link rel="icon" type="image/gif" href="images/favicon.gif"> </head> <body> <!-- ############HEADER TABLE############ --> <table width=100% height=100% border=1 bordercolor=#666666> <td valign=top class=table_head> <font color=#fefefe size=2> <div align=right> <?php ob_start(); // Connects to your Database mysql_connect("sql304.000a.biz", "a000b_4450564", "984497") or die(mysql_error()); mysql_select_db("a000b_4450564_BBT") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die (mysql_error()); echo '<font size=2 color=#ae854a>Welcome ' . $username . '</font> | <a href=myaccount.php>My Account</a> | <a href=logout.php>Logout</a>'; } else //if the cookie does not exist, they are taken to the login screen { echo '<font size=2 color=#fefefe><a href=register.php>Register</a> | <a href=login.php>Login</a> | Forgot Password'; } ob_end_flush(); ?> </div> </font> </td> </tr> </table> <!-- ############MAIN TABLE############ --> <table width=100% height=100% border=1 bordercolor=#666666 bgcolor=#242424> <td valign=top> <!-- ############LOGO TABLE############ --> <table width=88% border=0 align=center> <tr> <td valign=top> <img src=./images/101_logo.png> <img src=./images/slogan.png> <img src=./images/cellhead.png align=right> </td> </tr> </table> <!-- ############NAVIGATION TABLE############ --> <table width=100% border=0> <td valign=top> <br> <font color=#fefefe size=5> <center> <a href=index.php><img src=images/homeout.png border=0></a> <a href=gallery.php><img src=images/galleryout.png border=0></a> <a href=tutorials.php><img src=images/tutorialsout.png border=0></a> <a href=artists.php><img src=images/artistsout.png border=0></a> <a href=contact.php><img src=images/contactout.png border=0></a> </center> </font> </td> </tr> </table> </td> </tr> </table> <center>
  7. how about letting me know where to add this code so that it correctly displays the info when logged or not logged in. The echo bits i want in a table at the top which is already set up. <?php // Connects to your Database mysql_connect("sql304.000a.biz", "a000b_4450564", "984497") or die(mysql_error()); mysql_select_db("a000b_4450564_BBT") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die (mysql_error()); echo '<font size=2 color=#ae854a>Welcome ' . $username . '</font> | <a href=myaccount.php>My Account</a> | <a href=logout.php>Logout</a>'; } else //if the cookie does not exist, they are taken to the login screen { echo '<font size=2 color=#fefefe><a href=register.php>Register</a> | <a href=login.php>Login</a> | Forgot Password'; } ?>
  8. this is how it should be: and this is how it is now http://blender101.000a.biz/ like i said i moved all of the stuff in header.php that related to the cookies to the top of the script and had everything else below.
  9. okay there are now quotes around them, i was looking in the header file when you meant th elogin one. On the header file though i moved all of it to the top and the page doesnt display as it should now. This is what i moved to the top: <?php // Connects to your Database mysql_connect("sql304.000a.biz", "a000b_4450564", "984497") or die(mysql_error()); mysql_select_db("a000b_4450564_BBT") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users 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: login.php"); } //otherwise they are shown the admin area else { echo '<font size=2 color=#ae854a>Welcome ' . $username . '</font> | <a href=myaccount.php>My Account</a> | <a href=logout.php>Logout</a>'; } } } else //if the cookie does not exist, they are taken to the login screen { echo '<font size=2 color=#fefefe><a href=register.php>Register</a> | <a href=login.php>Login</a> | Forgot Password'; } ?> and my site is: http://blender101.000a.biz/
  10. i do have ' surrounding those things. Also what do i need o get rid of to correct the header? it looks for info within the cookie to see if the user is logged in then displays the corrent options, logout etc if not then it displays register etc
  11. okay i didnt fully understand you so here is the error code. you were right it is something to do with headers:
  12. i thought that question may come up, i just removed the connection settings cos when i try to edit on this forum and i have to scroll the box down it keeps jumping back up to the top when i type, so i just deleted them. they do display he correct connection settings in the code though
  13. also i should note i use both these includes on everything else and they work fine, i also have a footer which i include onto the base, which basically just closes the tables from the content holder. I just dont understand why it ws working last night and isnt now.
  14. okay here is the login script: <?php include'header.php'; include'contentholder.php'; // Connects to your Database mysql_connect("localhost", "myuser", "mypass") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: index.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['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users 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=add.php>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'])or die(mysql_error()); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour)or die(mysql_error()); setcookie(Key_my_site, $_POST['pass'], $hour)or die(mysql_error()); //then redirect them to the members area header("Location: index.php")or die(mysql_error()); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> here is header.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" dir="ltr" lang="en-gb" xml:lang="en-gb"> <head> <title>Blender 101 | Home</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="en-gb" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="resource-type" content="document" /> <meta name="distribution" content="global" /> <meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <link rel="stylesheet" href="stylesheet.css" type="text/css" /> <link rel="stylesheet" href="css/gallery.css" type="text/css" media="screen" charset="utf-8" /> <script src="scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script> <script src="scripts/mootools-1.2-more.js" type="text/javascript"></script> <script src="scripts/jd.gallery.js" type="text/javascript"></script> <script src="scripts/jd.gallery.transitions.js" type="text/javascript"></script> <link rel="icon" type="image/gif" href="images/favicon.gif"> </head> <body> <!-- ############HEADER TABLE############ --> <table width=100% height=100% border=1 bordercolor=#666666> <td valign=top class=table_head> <font color=#fefefe size=2> <div align=right> <?php // Connects to your Database mysql_connect("") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users 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: login.php"); } //otherwise they are shown the admin area else { echo '<font size=2 color=#ae854a>Welcome ' . $username . '</font> | <a href=myaccount.php>My Account</a> | <a href=logout.php>Logout</a>'; } } } else //if the cookie does not exist, they are taken to the login screen { echo '<font size=2 color=#fefefe><a href=register.php>Register</a> | <a href=login.php>Login</a> | Forgot Password'; } ?> </div> </font> </td> </tr> </table> <!-- ############MAIN TABLE############ --> <table width=100% height=100% border=1 bordercolor=#666666 bgcolor=#242424> <td valign=top> <!-- ############LOGO TABLE############ --> <table width=88% border=0 align=center> <tr> <td valign=top> <img src=./images/101_logo.png> <img src=./images/slogan.png> <img src=./images/cellhead.png align=right> </td> </tr> </table> <!-- ############NAVIGATION TABLE############ --> <table width=100% border=0> <td valign=top> <br> <font color=#fefefe size=5> <center> <a href=index.php><img src=images/homeout.png border=0></a> <a href=gallery.php><img src=images/galleryout.png border=0></a> <a href=tutorials.php><img src=images/tutorialsout.png border=0></a> <a href=artists.php><img src=images/artistsout.png border=0></a> <a href=contact.php><img src=images/contactout.png border=0></a> </center> </font> </td> </tr> </table> </td> </tr> </table> <center> and here is content holder.php <!-- ############CONTENT HOLDING TABLE############ --> <table width=100% height=100% border=0 bordercolor=#666666 class=table_content> <td valign=top> <br> <!-- ############CONTENT TABLE############ --> <table width=78% height=100% border=0 bordercolor=#666666 align=center> <tr> <td valign=top> <!-- ############LEFT TABLE############ --> <table border=1 width="14%" cellpadding="3" bordercolor=#fefefe cellspacing="3" align=left class=table_main> <th> <font color=#fefefe size=2> <center> Featured </center> </font> </th> <tr> <td valign=top> <center> <br> <img src=featured/cd1.jpg class=special> <br> <font color=#fefefe size=2>By Carl Dodds <br><br> <img src=featured/cd2.jpg class=special> <br> <font color=#fefefe size=2>By Carl Dodds <br><br> <img src=featured/cd3.jpg class=special> <br> <font color=#fefefe size=2>By Carl Dodds <br><br> <img src=featured/cd4.jpg class=special> <br> <font color=#fefefe size=2>By Carl Dodds <br><br> </td> </tr> </table> <!-- ############RIGHT TABLE############ --> <table border=1 width="14%" cellpadding="3" bordercolor=#fefefe cellspacing="3" align=right class=table_main> <th> <font color=#fefefe size=2> <center> Resources </center> </font> </th> <tr> <td valign=top> <center> <img src=images/blender.png> <br> <img src=images/blendercookie.png> <br><br> <img src=images/blendernation.jpg> <br><br> <img src=images/blenderunder.jpg> <br><br> <img src=images/rss.png> <img src=images/twit.png> <img src=images/fb.png> <img src=images/vim.png> </center> </td> </tr> </table> <!-- ############CENTER TABLE############ --> <table border=1 width="64%" cellpadding="3" cellspacing="3" bordercolor=#fefefe align=center class=table_main> <th> <center> <font color=#fefefe size=3> <center> <?php echo 'Today is ' . date("F j, Y, g:i a"); ?> </th> <tr> <td> <font color=#fefefe>
  15. there are alot of things tht can go wrong when just doing a site for IE and not thinking about others. for example if you hve a table with a border and dont define a border color IE ssumes its white, but firefox assumes its grey. I dont know about your problem though as ive never come accross it before. Can you post a link or some code?
  16. Okay i used this script http://php.about.com/od/finishedphp1/ss/php_login_code.htm to crete my system. everything worked last night hence the solved topic. But now it isnt. when i login the screen doesnt display anything bar my header and content holder. I have worked out why by trial and error. I use the include statement to include my header and main page before the content. I am doing: <?php include('header.php'); include('contentholder.php'); ?> When i only use one of these it works fine, but when i use both of them it breaks. I do however need both of them for the page to display properly. Any idea why this is happening? I can post my heder and content gholder scripts if tht helps.
  17. Cheers for the help guys, i think this is the only forum ive been to regardless of theme where i get reply within a few mins. Def bookmarked this one! Anywy tht tut worked like a charm, alredy working on a myaccount are. Cheers
  18. i read through that one and i doesnt seem to provide any clear help on this, yes it tells me how to do the login to cross check encrypted passwords but doesnt tell me how to send it to the db and encrypt it
  19. Hi, I am trying to do a user registration script for my site. I am fine doing forms and inserting to mysql database but I have no idea how to encrypt the password submitted on the form and insert the encrypted one into mysql, also i dont know how to do a login where it would check their pass against the encrypted one. Any help or guidelines?
×
×
  • 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.