JeanieTallis Posted March 15, 2009 Share Posted March 15, 2009 I have a login form that I have created myself. I have errors, I can register, perfectly fine, comes up on the database. However, when I login, it directs me to 'my account' which is what it should do, yet, it says I am signed out still. It's not registering me as logged in. I'll put the sufficient files you'll need to help me. (It's the whole website page do not copy the design for your website, its copyright) Index (login page) <link rel="stylesheet" href="emx_nav_left.css" type="text/css" /> <style type="text/css"> <!-- .style2 {color: #334d55} #Layer1 { position:absolute; width:975px; height:186px; z-index:1; left: 21px; top: 101px; } .style3 { font-size: 24px; font-weight: bold; color: #000000; } --> </style> <html> <title>Jeanies Poetry Corner - Login</title><body> <div id="masthead"> <h1 class="style2" id="siteName">Jeanies Poetry Corner </h1> <div id="globalNav"> <div align="center"> <!--end globalLinks--> <span class="style3">Login</span></div> </div> <!-- end globalNav --> <div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div> </div> <p align="center"> </p> <p align="center"> </p> <div id="Layer1"> <div align="center"> <?php include 'dbc.php'; $user_email = mysql_real_escape_string($_POST['email']); if ($_POST['Submit']=='Login') { $md5pass = md5($_POST['pwd']); $sql = "SELECT id,user_email FROM users WHERE user_email = '$user_email' AND user_pwd = '$md5pass' AND user_activated='1'"; $result = mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result); if ( $num != 0 ) { // A matching row was found - the user is authenticated. session_start(); list($user_id,$user_email) = mysql_fetch_row($result); // this sets variables in the session $_SESSION['user']= $user_email; if (isset($_GET['ret']) && !empty($_GET['ret'])) { header("Location: $_GET[ret]"); } else { header("Location: myaccount.php"); } //echo "Logged in..."; exit(); } header("Location: login.php?msg=Invalid Login"); //echo "Error:"; exit(); } ?> <link href="styles.css" rel="stylesheet" type="text/css"> <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?> <table width="40%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#FFFFFF" class="mnuheader" > </td> </tr> <tr> <td bgcolor="#FFFFFF" class="mnubody"><form name="form1" method="post" action=""> <p align="center">Your Email <input name="email" type="text" id="email"> </p> <p align="center"> Password: <input name="pwd" type="password" id="pwd"> </p> <p align="center"> <input type="submit" name="Submit" value="Login"> </p> <p align="center"><a href="register.php">Register</a> | <a href="forgot.php">Forgot</a></p> </form></td> </tr> </table> <p> </p> Register Page <link rel="stylesheet" href="emx_nav_left.css" type="text/css" /> <style type="text/css"> <!-- .style2 {color: #334d55} .style3 { color: #000000; font-size: large; } #Layer1 { position:absolute; width:975px; height:186px; z-index:1; left: 21px; top: 101px; } .style4 { color: #000000; font-weight: bold; } --> </style> <html> <title>Jeanies Poetry Corner - Register!</title><body> <div id="masthead"> <h1 class="style2" id="siteName">Jeanies Poetry Corner </h1> <div id="globalNav"> <div align="center"> <!--end globalLinks--> <span class="style3">Register!</span></div> </div> <!-- end globalNav --> <div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div> </div> <p align="center"> </p> <p align="center"> </p> <div id="Layer1"> <div align="center"> <?php session_start(); include ('dbc.php'); if ($_POST['Submit'] == 'Register') { if (strlen($_POST['email']) < 5) { die ("Incorrect email. Please enter valid email address.."); } if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) ) { //die ("Password does not match"); die("ERROR: Password does not match or empty.."); } if (strcmp(md5($_POST['user_code']),$_SESSION['ckey'])) { die("Invalid code entered. Please enter the correct code as shown in the Image"); } $rs_duplicates = mysql_query("select id from users where user_email='$_POST[email]'"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { //die ("ERROR: User account already exists."); header("Location: register.php?msg=ERROR: User account already exists.."); exit(); } $md5pass = md5($_POST['pass2']); $activ_code = rand(1000,9999); mysql_query("INSERT INTO users (`user_email`,`user_pwd`,`country`,`joined`,`activation_code`,`full_name`) VALUES ('$_POST[email]','$md5pass','$_POST[country]',now(),'$activ_code','$_POST[full_name]')") or die(mysql_error()); $message = "Thank you for registering an account with Jeanies Poetry. Here are the login details...\n\n User Email: $_POST[email] \n Password: $_POST[pass2] \n Activation Code: $activ_code \n ____________________________________________ *** ACTIVATION LINK ***** \n Activation Link: http://jeanies-poetry.com/activate.php?usr=$_POST[email]&code=$activ_code \n\n _____________________________________________ Thank you. This is an automated response. PLEASE DO NOT REPLY. "; mail($_POST['email'] , "Login Activation", $message, "From: \"Auto-Response\" <notifications@jeanies-poetry.com>\r\n" . "X-Mailer: PHP/" . phpversion()); unset($_SESSION['ckey']); echo("Registration Successful! An activation code has been sent to your email address with an activation link..."); exit; } ?> <link href="styles.css" rel="stylesheet" type="text/css"> <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?> <table width="38%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="18" bgcolor="FFFFFF" class="mnuheader"> </td> </tr> <tr> <td bgcolor="FFFFFF" class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;"> <p align="left">Name: <input name="full_name" type="text" id="full_name"> Ex. John Wilson</p> <p align="left">Email: <input name="email" type="text" id="email"> Ex. john@domain.com</p> <p align="left">Password: <input name="pass1" type="password" id="pass1"> Atleast 5 chars</p> <p align="left">Retype Password: <input name="pass2" type="password" id="pass2"> </p> <p align="left">Country: <select name="country" id="select8"> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Anguila">Anguila</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaidjan">Azerbaidjan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Brazil">Brazil</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmans Islands">Christmans Islands</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Estonia">Estonia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guyana">French Guyana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Germany">Germany</option> <option value="Gibraltar">Gibraltar</option> <option value="Georgia">Georgia</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guinea">Guinea</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati ">Kiribati </option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia ">Malaysia </option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marocco">Marocco</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldavia">Moldavia</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Myanmar">Myanmar</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="Netherlands">Netherlands</option> <option value="New Zealand">New Zealand</option> <option value="Niue">Niue</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru ">Peru </option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Portugal ">Portugal </option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Korea Reunion">Republic of Korea Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Saint Helena">Saint Helena</option> <option value="Saint kitts and nevis">Saint kitts and nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Samoa">Samoa</option> <option value="San Marino">San Marino</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Seychelles">Seychelles</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St.Pierre and Miquelon">St.Pierre and Miquelon</option> <option value="St.Vincent and the Grenadines">St.Vincent and the Grenadines</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Taiwan ">Taiwan </option> <option value="Tajikistan">Tajikistan</option> <option value="Thailand">Thailand</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Islands">Turks and Caicos Islands</option> <option value="Ukraine">Ukraine</option> <option value="UAE">UAE</option> <option value="UK" selected="selected">UK</option> <option value="USA">USA</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (GB)">Virgin Islands (GB)</option> <option value="Virgin Islands (U.S.) ">Virgin Islands (U.S.) </option> <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option> <option value="Yemen">Yemen</option> <option value="Yugoslavia">Yugoslavia</option> </select> </p> <p align="left"> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle"> </p> <p align="left"> <input type="submit" name="Submit" value="Register"> </p> </form></td> </tr> </table> </div> <div align="left"></div> </body> </html> DBC page <?php $dbhost = 'localhost'; $dbusername = 'jeanies'; $dbpasswd = 'docaf9'; $database_name = 'jeanies_Login'; $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server."); $db = mysql_select_db("$database_name", $connection) or die("Couldn't select database."); include('check_login.php'); ?> Check_login page <?php session_start(); if (!isset($_SESSION['email']) || !isset($_SESSION['pwd'])) { $logged_in = 0; return; } else { // remember, $_SESSION['password'] will be encrypted. if(!get_magic_quotes_gpc()) { $_SESSION['email'] = addslashes($_SESSION['email']); } // addslashes to session username before using in a query. $qry = "SELECT password FROM users WHERE username = '".$_SESSION['email']."'"; $sqlmembers = mysql_query($qry); $pass = mysql_num_rows($sqlmembers); if($pass != 1) { $logged_in = 0; unset($_SESSION['email']); unset($_SESSION['pwd']); // kill incorrect session variables. } $db_pass = mysql_fetch_array ($sqlmembers); // now we have encrypted pass from DB in //$db_pass['password'], stripslashes() just incase: $db_pass['pwd'] = stripslashes($db_pass['pwd']); $_SESSION['pwd'] = stripslashes($_SESSION['pwd']); //compare: if($_SESSION['pwd'] == $db_pass['pwd']) { // valid password for username $logged_in = 1; // they have correct info // in session variables. } else { $logged_in = 0; unset($_SESSION['email']); unset($_SESSION['pwd']); // kill incorrect session variables. } } // clean up unset($db_pass['pwd']); $_SESSION['email'] = stripslashes($_SESSION['email']); ?> My account page <title>Jeanies Poetry Corner - My Account</title> <link rel="stylesheet" href="emx_nav_left.css" type="text/css" /> <style type="text/css"> <!-- .style2 {color: #334d55} .style4 { font-size: 120%; color: #000000; font-weight: bold; } .style7 {font-size: 36%} --> </style></head> <body onmousemove="closesubnav(event);"> <div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="#pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div> <div id="masthead"> <h1 class="style2" id="siteName">Jeanies Poetry Corner </h1> <div id="globalNav"> <div id="globalLink"> <a href="http://www.jeanies-poetry.com/homepage.php" id="gl1" class="glink" onMouseOver="ehandler(event,menuitem1);"> Homepage </a><a href="http://www.jeanies-poetry.com/Poetry.php" id="gl2" class="glink" onMouseOver="ehandler(event,menuitem2);"> Poetry </a><a href="http://www.jeanies-poetry.com/Aims.php" id="gl3" class="glink" onMouseOver="ehandler(event,menuitem3);"> Aims </a><a href="http://www.Jeanies-Poetry.com/Updates.php" id="gl4" class="glink" onMouseOver="ehandler(event,menuitem4);"> Updates </a><a href="http://www.jeanies-poetry.com/Contact.php" id="gl5" class="glink" onMouseOver="ehandler(event,menuitem5);"> Contact Us </a><a href="http://www.jeanies-poetry.com/Advertisement.php" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);"> Advertisement</a> <a href="http://www.jeanies-poetry.com/Jobs.php" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);"> Job Vacancies </a><a href="http://www.jeanies-poetry.com/PPDon.php" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);"> Paypal Donation </a><a href="http://www.jeanies-poetry.com/forum" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);"> Forum </a></div> <!--end globalLinks--> </div> <!-- end globalNav --> <div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div> </div> <!-- end masthead --> <div id="pagecell1"> <!--pagecell1--> <div id="pageName"> <h2 class="style2">My Account<a href="http://www.discount-luggage.net/" ></a><img src="http://www.imghostsrc.com/SHOULDER_BAG_3770559.jpg"/><br> <span class="style7"><a href="http://www.jeanies-poetry.com/logout.php">LOG OUT</a></span> </h2> </div> <div id="pageNav"> <div id="sectionLinks"> <p><a href="http://www.jeanies-poetry.com/LR.php">Love & Romance </a> <a href="http://www.jeanies-poetry.com/FF.php">Friendship & Family </a> <a href="http://www.jeanies-poetry.com/FH.php">Fun & Humor </a> <a href="http://www.jeanies-poetry.com/LS.php">Life & Society </a> <a href="http://www.jeanies-poetry.com/NE.php">Nature & Environment </a> <a href="http://www.jeanies-poetry.com/DF.php">Dark & Fantasy</a><a href="http://www.jeanies-poetry.com/SE.php">Special Events</a><a href="http://www.jeanies-poetry.com/IS.php">Internet Slang </a></p> </div> <div class="relatedLinks">Advertisement space here. Contact the advertisement page if you want you advert here.</div> <div class="relatedLinks"> <h3>Related Link Category</h3> <a href="http://www.poems-and-quotes.com/">Poems & Quotes</a><a href="http://www.gigglepoetry.com/">Poetry For Children</a><a href="http://www.poetryarchive.org/">Poetry Archive</a><a href="http://www.poetrysociety.org.uk/">Poetry Society</a><a href="http://www.poetryfoundation.org/poetrymagazine/">Poetry Magazine</a><a href="http://www.poetry4kids.com/">Poetry For Kids</a></div> <div id="advert"> Advertisement space here. Contact the advertisement page if you want you advert here. </div> </div> <div id="content"> <div class="feature"> <div align="center"><span class="style4">My Account</span> </div> <?php require 'dbc.php'; if ($logged_in == 0) { ?> You must be logged in to access this area; <a href="http://www.jeanies-poetry.com">Login</a> <?php } else { ?> <p>Logged as <?php echo $_SESSION['user']; ?> | <a href="http://www.jeanies-poetry.com/settings.php">Change Password</a> | <a href="http://www.jeanies-poetry.com/logout.php">Logout</a> </p> <?php } ?> </div> <div id="siteInfo"><a href="#"></a><a href="http://www.jeanies-poetry.com/Policy.php">Privacy Policy</a> | <a href="http://www.jeanies-poetry.com/Contact.php">Contact Us</a> | ©2009 Jeanies Poetry Corner </div> </div> </body> </html> Alot of the my account page, will be a bit, screwed up. There is alot of template junk I need to get rid of. Ignore all that, just focus on the login. I don't think theres anything wrong with the myaccount page, I think it's mostly to do with check_login page, as its not checking im logged in properly. I'm guessing alot of the "&_SESSION" parts are all incorrect. I have no idea how to put it right. I coded this all out myself, I used 2 templates for login forms, I put them on my websites, and then I decided to make a more secure one that actually worked 100% The first one seemed to like, logme out alot of the times, or sometimes didn't realise I was meant to be logged in. The second, had problems with seeing if i was logged in. I then used both templates, put them both together. They both had there own errors, and weaknesses. I came up with a good design, its just not checking I'm logged in. All files are above. I'll add attachments too just incase. If you need any other files, comment and ill put in. Hope you can help. Jeanie [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/ Share on other sites More sharing options...
JeanieTallis Posted March 15, 2009 Author Share Posted March 15, 2009 More attachments (if needed) P.S all the attachments given, are all the login parts. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785354 Share on other sites More sharing options...
JeanieTallis Posted March 15, 2009 Author Share Posted March 15, 2009 Post your corrects in the codes would be the best option please. http://www.jeanies-poetry.com if you want to register and look for yourself, your more than welcome to. If you want your account deleted, comment back and I'll remove it from the database, choice is yours. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785360 Share on other sites More sharing options...
Renlok Posted March 15, 2009 Share Posted March 15, 2009 thats a lot to look though but maybe change if ($logged_in == 0) { to if(isset($_SESSION['user'])) { as im not sure but it doesnt look like $logged_in is set anywhere Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785363 Share on other sites More sharing options...
JeanieTallis Posted March 15, 2009 Author Share Posted March 15, 2009 Thanks for that code, I just tested it, and now it shows the page that should be shown if your logged in, but without the username. Then if I tried if(!isset($_SESSION['user'])) { Then it shows the page that I should recieve if I'm not logged in, so either way. It still doesn't recognise Im logged in. Any other suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785367 Share on other sites More sharing options...
jlhaslip Posted March 15, 2009 Share Posted March 15, 2009 In your login page, you need to set the Session[pwd] value. You can not set the value in the login-check page and test it on the same page. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785454 Share on other sites More sharing options...
JeanieTallis Posted March 15, 2009 Author Share Posted March 15, 2009 Thank you for that, i'll continue working on it, i got some ideas. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785489 Share on other sites More sharing options...
JeanieTallis Posted March 15, 2009 Author Share Posted March 15, 2009 In your login page, you need to set the Session[pwd] value. You can not set the value in the login-check page and test it on the same page. <link rel="stylesheet" href="emx_nav_left.css" type="text/css" /> <style type="text/css"> <!-- .style2 {color: #334d55} .style3 { color: #000000; font-size: large; } #Layer1 { position:absolute; width:975px; height:186px; z-index:1; left: 21px; top: 101px; } .style4 { color: #000000; font-weight: bold; } --> </style> <html> <title>Jeanies Poetry Corner - Register!</title><body> <div id="masthead"> <h1 class="style2" id="siteName">Jeanies Poetry Corner </h1> <div id="globalNav"> <div align="center"> <!--end globalLinks--> <span class="style3">Register!</span></div> </div> <!-- end globalNav --> <div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div> </div> <p align="center"> </p> <p align="center"> </p> <div id="Layer1"> <div align="center"> <?php include ('dbc.php'); if (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they supposed to, passwords matched, username isn't already taken, etc. */ if (!$_POST['uname'] || !$_POST['passwd'] || !$_POST['passwd_again'] || !$_POST['email']) { die('You did not fill in a required field.'); } if (strcmp(md5($_POST['user_code']),$_SESSION['ckey'])) { die("Invalid code entered. Please enter the correct code as shown in the Image"); } if (!get_magic_quotes_gpc()) { $_POST['uname'] = addslashes($_POST['uname']); } $qry = "SELECT username FROM users WHERE username = '".$_POST['uname']."'"; $sqlmembers = mysql_query($qry); $name_check = mysql_fetch_array ($sqlmembers); $name_checkk = mysql_num_rows ($sqlmembers); if ($name_checkk != 0) { die('Sorry, the username: <strong>'.$_POST['uname'].'</strong>' . ' is already taken, please pick another one. Click back.'); } if ($_POST['passwd'] != $_POST['passwd_again']) { die('Passwords did not match.'); } if (!preg_match("/.*@.*..*/", $_POST['email']) || preg_match("/(<|>)/", $_POST['email'])) { die('Invalid e-mail address.'); } $_POST['uname'] = strip_tags($_POST['uname']); $_POST['passwd'] = strip_tags($_POST['passwd']); $_POST['website'] = strip_tags($_POST['website']); $_POST['location'] = strip_tags($_POST['location']); if (!get_magic_quotes_gpc()) { $_POST['passwd'] = addslashes($_POST['passwd']); $_POST['email'] = addslashes($_POST['email']); $_POST['location'] = addslashes($_POST['location']); } $regdate = date('m d, Y'); $md5pass = md5($_POST['passwrd_again']); $activ_code = rand(1000,9999); mysql_query("INSERT INTO users (`uname`,`email`,`passwd`,`location`,`regdate`,`activation_code`,`full_name`) VALUES ('$_POST[uname]','$_POST[email]','$md5pass','$_POST[country]','$regdate','$activ_code','$_POST[full_name]')") or die(mysql_error()); $message = "Dear $_POST[full_name] \n Thank you for registering an account with Jeanies Poetry. Here are the login details...\n\n Username: $_POST[uname] \n User Email: $_POST[email] \n Password: $_POST[passwrd_again] \n Activation Code: $activ_code \n ____________________________________________ *** ACTIVATION LINK ***** \n Activation Link: http://jeanies-poetry.com/activate.php?usr=$_POST[email]&code=$activ_code \n\n _____________________________________________ Thank you. This is an automated response. PLEASE DO NOT REPLY. "; mail($_POST['email'] , "Login Activation", $message, "From: \"Auto-Response\" <notifications@jeanies-poetry.com>\r\n" . "X-Mailer: PHP/" . phpversion()); unset($_SESSION['ckey']); echo("Registration Successful! An activation code has been sent to your email address with an activation link..."); exit; } ?> <table width="31%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="18" bgcolor="FFFFFF" class="mnuheader"> </td> </tr> <tr> <td bgcolor="FFFFFF" class="forumposts"><form method="post" action="?<?php echo $_SERVER['PHP_SELF']; ?>" style="padding:5px;"> <p align="left">Name: <input name="full_name" type="text" maxlength="60"> <br> Ex. Meese Parker</p> <p align="left">Username: <input name="uname" type"text" maxlength="40"> <br> Ex. meeseparker <p align="left">Email: <input name="email" type="text" maxlength="100"> <br> Ex. MP@domain.com</p> <p align="left">Password: <input name="passwd" type="password" maxlength="50"> <br> Atleast 5 chars</p> <p align="left">Retype Password: <input name="passwd_again" type="password" maxlength="50"> </p> <p align="left">Country: <select name="location"> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Anguila">Anguila</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaidjan">Azerbaidjan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Brazil">Brazil</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmans Islands">Christmans Islands</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Estonia">Estonia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guyana">French Guyana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Germany">Germany</option> <option value="Gibraltar">Gibraltar</option> <option value="Georgia">Georgia</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guinea">Guinea</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati ">Kiribati </option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia ">Malaysia </option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marocco">Marocco</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldavia">Moldavia</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Myanmar">Myanmar</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="Netherlands">Netherlands</option> <option value="New Zealand">New Zealand</option> <option value="Niue">Niue</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru ">Peru </option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Portugal ">Portugal </option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Korea Reunion">Republic of Korea Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Saint Helena">Saint Helena</option> <option value="Saint kitts and nevis">Saint kitts and nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Samoa">Samoa</option> <option value="San Marino">San Marino</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Seychelles">Seychelles</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St.Pierre and Miquelon">St.Pierre and Miquelon</option> <option value="St.Vincent and the Grenadines">St.Vincent and the Grenadines</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Taiwan ">Taiwan </option> <option value="Tajikistan">Tajikistan</option> <option value="Thailand">Thailand</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Islands">Turks and Caicos Islands</option> <option value="Ukraine">Ukraine</option> <option value="UAE">UAE</option> <option value="UK" selected="selected">UK</option> <option value="USA">USA</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (GB)">Virgin Islands (GB)</option> <option value="Virgin Islands (U.S.) ">Virgin Islands (U.S.) </option> <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option> <option value="Yemen">Yemen</option> <option value="Yugoslavia">Yugoslavia</option> </select> </p> <p> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle"> </p> <p> <input type="submit" name="submit" value="Register"> </p> </form></td> </tr> </table> </div> <div align="left"></div> </body> </html> Error is; Unknown column 'uname' in 'field list' This error, is when I fill in the registerform and click submit. What could be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785502 Share on other sites More sharing options...
jlhaslip Posted March 16, 2009 Share Posted March 16, 2009 What line number on the error? I see that the $_POST array elements sometimes includes single quotes and other times they are missing. I am thinking it is best to have them in there. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785515 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 Im not too sure for the line error, thats all that comes up. All I know is that it has something to do with "uname" Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785517 Share on other sites More sharing options...
Philip Posted March 16, 2009 Share Posted March 16, 2009 Unknown column 'uname' in 'field list' That's in your insert query - and it means that cokumn doesn't exist in your database structure. Are you sure you have a 'uname' and not 'uName' or 'username' or something like that? Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785519 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 Unknown column 'uname' in 'field list' That's in your insert query - and it means that cokumn doesn't exist in your database structure. Are you sure you have a 'uname' and not 'uName' or 'username' or something like that? Thanks! I also single quoted all of those $_POST Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785520 Share on other sites More sharing options...
jlhaslip Posted March 16, 2009 Share Posted March 16, 2009 Can you post the SQL from the Table creation, please. If you are using the Login system found here, and the MySql from the same place, there is not a MySql Field named 'uname'. It refers to 'user_name' which would throw this error. *edit* What they said... Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785523 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 Can you post the SQL from the Table creation, please. If you are using the Login system found here, and the MySql from the same place, there is not a MySql Field named 'uname'. It refers to 'user_name' which would throw this error. *edit* What they said... KingPhilip helped, I can now register, this comes up Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jeanies/public_html/register.php on line 65 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jeanies/public_html/register.php on line 66 when i click register, aswell as it says I am registered. Line 65 and 66 are; $name_check = mysql_fetch_array ($sqlmembers); $name_checkk = mysql_num_rows ($sqlmembers); Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785531 Share on other sites More sharing options...
Philip Posted March 16, 2009 Share Posted March 16, 2009 Change $sqlmembers = mysql_query($qry); to $sqlmembers = mysql_query($qry) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785538 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 Change $sqlmembers = mysql_query($qry); to $sqlmembers = mysql_query($qry) or die(mysql_error()); now I get a similar error to what I have before Unknown column 'username' in 'field list' yet everything is set as uname. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785544 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 It's done guys, just little bits to cover, <?php require 'dbc.php'; if ($logged_in == 0) { ?> <center> You must be logged in to access this area; <a href="http://www.jeanies-poetry.com">Login</a> </center> <?php } else { ?> <center><p>Logged as <?php echo $_SESSION['username']; ?> | <a href="http://www.jeanies-poetry.com/settings.php">Account Settings</a> | <a href="http://www.jeanies-poetry.com/logout.php">Logout</a> </p></center> <?php } ?> It doesn't display the username logged in. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785552 Share on other sites More sharing options...
Solar Posted March 16, 2009 Share Posted March 16, 2009 <?php require 'dbc.php'; if ($logged_in == 0) { ?> <center> You must be logged in to access this area; <a href="http://www.jeanies-poetry.com">Login</a> </center> <?php } else { ?> <center><p>Logged as <?php echo "$_SESSION['username']"; ?> | <a href="http://www.jeanies-poetry.com/settings.php">Account Settings</a> | <a href="http://www.jeanies-poetry.com/logout.php">Logout</a> </p></center> <?php } ?> Does an echo need quotations around itself? Like above? Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785565 Share on other sites More sharing options...
Solar Posted March 16, 2009 Share Posted March 16, 2009 ^ Nevermind about my above post, I tried it myself and it works fine for myself. "<?php echo $_SESSION['username']; ?>" So its not displaying because you didn't include.. Check_login.php? Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785599 Share on other sites More sharing options...
Philip Posted March 16, 2009 Share Posted March 16, 2009 Do you have session_start(); at the very top of the page you're trying to use the session with? Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785604 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 I do not have session_Start() should that be included at the top of the page im trying to get the username in (the post i put) or the dbc.php file? and check_login, is in dbc.php Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785675 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 I tried session_Start(); and it doesn't work ether. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785685 Share on other sites More sharing options...
Philip Posted March 16, 2009 Share Posted March 16, 2009 It should be like this: main.php <?php session_start(); include somefile.php; echo 'hi'; ?> somefile.php <?php echo $_SESSION['name']; ?> Also, add error_reporting(E_ALL); at the very top of your script Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785721 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 It should be like this: main.php <?php session_start(); include somefile.php; echo 'hi'; ?> somefile.php <?php echo $_SESSION['name']; ?> Also, add error_reporting(E_ALL); at the very top of your script Thanks, i have a file http://www.jeanies-poetry.com/JeaniesPoetry.rar it has a text file of all the errors, would you kindly fix it all for me and make it all look 'tidy' in designer mode too, and send it back. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-785742 Share on other sites More sharing options...
.josh Posted March 16, 2009 Share Posted March 16, 2009 Thanks, i have a file http://www.jeanies-poetry.com/JeaniesPoetry.rar it has a text file of all the errors, would you kindly fix it all for me and make it all look 'tidy' in designer mode too, and send it back. Thanks. Yeah KingPhilip, and he wants it on his desk by Friday, or you're fired! Quote Link to comment https://forums.phpfreaks.com/topic/149553-errors-within-login-form-help/#findComment-786167 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.