PHP - So Confused Why This Is Happening To Login
ok so I'll login to my account then once I'm logged in I visit a page with a: while(mysql_fetch_array($v)){
in it and it logs me in as someone else. if I remove the while it wont but I need to while. what do I do and whys it doing this? Login: <?php $title="Login"; $metakeywords="login, email"; $metadescription="Login to $sitename"; include("header.php"); if(!$_POST['submit']) { ?> <html> <div class="header">Login</div> <div class="content"> <form method="post" action="index.php?action=login"> Email:<br /> <input id="email" type="text" name="email" maxlength="16"> <br /> Password:<br /> <input type="password" name="password" maxlength="16"> <br /> <input type="submit" name="submit" value="Login"> </form> <a href="index.php?action=signup">Register Here</a> </div> </html> <?php } else { $user = protect($_POST['email']); $pass = protect($_POST['password']); if($user && $pass) { $pass = md5($pass); //compare the encrypted password $sql="SELECT id,email,password,activation_key FROM `users` WHERE `email`='$user' AND `password`='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { $row = mysql_fetch_assoc($query); if($row['activation_key'] == 0){ $_SESSION['id'] = $row['id']; $_SESSION['email'] = $row['email']; $_SESSION['password'] = $row['password']; echo '<meta http-equiv="REFRESH" content="0;url=index.php">'; }else{ echo "<div class='error'>You need to activate your account first!</div>"; } } else { echo "<div class='error'>Email and password combination is incorrect!</div>"; } } else { echo "<div class='error'>You need to gimme a email AND password!</div>"; } } include("footer.php"); ?> code that logs me into another account: $sql2 = "select * FROM cheats WHERE game_id='$datas[id]'"; $rec2 = mysql_query($sql2) or die(mysql_error()); while($datas2=mysql_fetch_array($rec2)){ echo "<div class='header'>$datas2[title]</div>"; echo "<div class='content'>$datas2[cheat]</div><br>"; } Similar TutorialsOver the last few weeks I have had people trying to access the following urls and some similar index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b by BOT for JCE /includes/exit.php?ID=999999.9 /*!30000union all select 0x31303235343830303536,0x31303235343830303536,0x31303235343830303536,0x31303235343830303536,0x31303235343830303536,0x31303235343830303536,0x31303235343830303536,0x3130323 /index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b what are these urls trying to do and should I be worried? James Edited by requinix, 24 May 2014 - 03:56 AM. unlinking Hi all I have several arrays set, and I can guarantee I have values in these as I have tested them by echoing out each value. However, when I pass it through a user defined function to produce a percentage for each value of the total arry, I get a null return. I don't even get any errors. Any ideas? // Produce the % array of each array for use in 2nd report $percent_morale1=percentCalc($morale_count1[1],$morale_count1[2],$morale_count1[3],$morale_count1[4],$morale_count1[5],$total_morale1); $percent_morale2=percentCalc($morale_count2[1],$morale_count2[2],$morale_count2[3],$morale_count2[4],$morale_count2[5],$total_morale2); $percent_morale3=percentCalc($morale_count3[1],$morale_count3[2],$morale_count3[3],$morale_count3[4],$morale_count3[5],$total_morale3); $percent_morale4=percentCalc($morale_count4[1],$morale_count4[2],$morale_count4[3],$morale_count4[4],$morale_count4[5],$total_morale4); $percent_morale5=percentCalc($morale_count5[1],$morale_count5[2],$morale_count5[3],$morale_count5[4],$morale_count5[5],$total_morale5); $percent_morale6=percentCalc($morale_count6[1],$morale_count6[2],$morale_count6[3],$morale_count6[4],$morale_count6[5],$total_morale6); <?php function percentCalc($value1,$value2,$value3,$value4,$value5,$total) { $array=array($value1,$value2,$value3,$value4,$value5); while (list($key,$arraycontent)= each($array)) { $c_percent=(($arraycontent/$total)*100); $final_array[]=$c_percent; } return $final_array; } ?> <?php echo"<td class=\"percent1\" > "; printf("%01.0f",$percent_morale1[1]); echo "%</td>"; echo"<td class=\"percent2\" > "; printf("%01.0f",$percent_morale1[2]); echo "%</td>"; echo"<td class=\"percent3\" > "; printf("%01.0f",$percent_morale1[3]); echo "%</td>"; echo"<td class=\"percent4\" > "; printf("%01.0f",$percent_morale1[4]); echo "%</td>"; echo"<td class=\"percent5\" > "; printf("%01.0f",$percent_morale1[5]); echo "%</td>"; ?> Hi, I am having trouble with some GIF, PNG images the error I am receiving these errors imagecreatefromgif() [function.imagecreatefromgif]: '/tmp/phpNAhLPI' is not a valid GIF and a similar one for PNG Is there a solution to this? and How can I hide these errors? So they never display to the user and Instead I echo a user friendly error. Please note again this is happening with some GIF and PNGs not all of them. Appreciate any help and thanks in advance! EDIT: Solved. I was calling duplicate variables from an include. Changing the name in this code to something (could be anything really) different fixed the issue. Thanks!! I am currently working on some PHP which grabs variables from the link so I can keep track of which user has been clicked on. Everything seemed to be working just fine until I got to a particular part of the code. Let me know if this makes any sense AT ALL!!! As usual my code can be found below. Thanks!! Code: [Select] <?php session_start(); // Put stored session variables into local php variable $staff_id = $_SESSION['sid']; $staff_username = $_SESSION['username']; $staff_fname = $_SESSION['staff_first_name']; $cust_edit_access = $_SESSION['cust_edit_access']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $customer_project_id = $_GET['pid']; $customer_project_id = mysql_real_escape_string($customer_project_id ); $customer_project_id = eregi_replace("`", "", $customer_project_id ); include "left_nav_customers.php"; include "left_nav_tools.php"; include "pgbdy_header_left.php"; include "project_display.php"; $sql = mysql_query("SELECT * FROM company_info WHERE proj_id='$customer_project_id'"); while ($row = mysql_fetch_array($sql)) { $company_name = $row["company_name"]; $customer_address = $row["address"]; $customer_city = $row["city"]; $customer_state = $row["state"]; $customer_zip = $row["zip"]; $customer_email = $row["email"]; $customer_phone = $row["phone"]; $customer_fax = $row["fax"]; $cust_pre_meth_contact = $row["pref_meth_contact"]; $cust_entry_date = $row["entry_date"]; } $temp_project_id = ''; $start_date = date("F j, Y, g:i:s a"); $start_month = date('n'); if ($_POST['create_new_customer_project']) { $sql2 = mysql_query("INSERT INTO projects (cust_id, staff_id, start_date) VALUES('$customer_id','$staff_id','$start_date')") or die (mysql_error()); // Get the inserted ID here to use in the activation email $new_project_id = mysql_insert_id(); // Create directory(folder) to hold each user files(pics, MP3s, etc.) $temp_project_id = "$start_month-00$customer_id-0$new_project_id"; mkdir("customer_files/cust$customer_id/$temp_project_id", 0755); $sql3 = mysql_query("UPDATE projects SET proj_id='$temp_project_id' WHERE id='$new_project_id'"); } ?> <!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>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <!----------- ALL JAVASCRIPT ------------------------ ==================================================--> <script src="js/jquery-1.5.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function toggleSlideBox(x) { if ($('#'+x).is(":hidden")) { $(".hiddenDiv").slideUp(200); $('#'+x).slideDown(300); } else { $('#'+x).slideUp(300); } } </script> <!--===========COMPANY INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- function edit_company_info() { window.open( "edit_company_info.php?sid=<?php echo "$staff_id"; ?>&cid=<?php echo "$customer_id"; ?>&pid=<?php echo "$customer_project_id"; ?>", "myWindow", "status = 1, toolbar = no, scrollbars = no, location = no, resizable = no, height = 580, width = 600, resizable = 0" ) } //--> </script> <!--===========COMPANY INFO POPUP==============-- ==============================================--> <!--===========GENERAL INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- function edit_general_info() { window.open( "http://www.google.com/", "myWindow", "status = 1, toolbar = no, scrollbars = no, location = no, resizable = no, height = 600, width = 600, resizable = 0" ) } //--> </script> <!--===========GENERAL INFO POPUP==============-- ==============================================--> <!--===========BILLING INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- function edit_billing_info() { window.open( "http://www.google.com/", "myWindow", "status = 1, toolbar = no, scrollbars = no, location = no, resizable = no, height = 600, width = 600, resizable = 0" ) } //--> </script> <!--===========BILLING INFO POPUP==============-- ==============================================--> <!--===========FACILITY INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- function edit_facility_info() { window.open( "http://www.google.com/", "myWindow", "status = 1, toolbar = no, scrollbars = no, location = no, resizable = no, height = 600, width = 600, resizable = 0" ) } //--> </script> <!--===========FACILITY INFO POPUP==============-- ==============================================--> <!--===========PRODUCT NEEDS INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- function edit_product_needs_info() { window.open( "http://www.google.com/", "myWindow", "status = 1, toolbar = no, scrollbars = no, location = no, resizable = no, height = 600, width = 600, resizable = 0" ) } //--> </script> <!--===========PRODUCT NEEDS INFO POPUP==============-- ==============================================--> <script type="text/javascript"> <!-- var sURL = unescape(window.location.pathname); function refresh() { window.location.href = sURL; } //--> </script> <!----------- ALL JAVASCRIPT ------------------------ ==================================================--> </head> <body> <div id="pg_container"> <!--HEADER SECTION--> <div id="header"> <div id="header_logo"></div> <div id="header_right"> Welcome <a href="template.php?id=<?php echo "$staff_id"; ?>"><?php echo $staff_fname; ?></a> | <a href="logout.php">Logout</a> </div> </div> <!--HEADER SECTION--> <!--PAGE CONTAINER--> <div id="pgbdy_container"> <div id="left_nav"> <div id="leftnav_header"></div> <div id="leftnav_bdy"> <div id="leftnav_content"> <div id="leftnav_customers"> <p> Select a Customer:<br /><br /> <?php echo "$list_customers"; ?> </p> </div> <hr /> <?php if($cust_edit_access == "1") { ?> <div id="leftnav_tools"> <p> <?php echo "$leftnav_links"; ?> </p> </div> <?php } else { ?> <div id="leftnav_tools"> <p> Edit Customers<br /><br /> You do not have access to edit customers. </p> </div> <?php } ?> </div> </div> </div> <div id="pgbdy"> <div id="bdy_header"></div> <div id="bdy_content_area"> <div id="bdy_content"> <div id="bdy_content_header"> <div id="bdy_content_selected_customer"> <p><?php echo "$contact_info_display"; ?></p> </div> <div id="bdy_content_current_projects"> <form action="customer_profile.php?sid=<?php echo "$staff_id"; ?>&cid=<?php echo "$customer_id"; ?>" method="post" enctype="multipart/form-data"> <p> Customer Projects <input name="create_new_customer_project" type="submit" class="create_new_customer_project_btn" value="" /><br /><br /> <?php echo "$list_customer_projects"; ?> </p> </form> </div> </div> <hr /> <div id="bdy_content_container"> <div id="company_information_section"> <a href="#" onclick="return false" onmousedown="javascript:toggleSlideBox('company_infoBox');">Company Information</a> <div class="hiddenDiv" id="company_infoBox" style="border:#FFF 2px solid; width:553px;"> <p>Please click the button below to edit the customer's company information.<br /> <input name="edit_company_info" onclick="edit_company_info()" type="button" value="Edit Company Information"/><br /><br /> //i placed this here just to make sure the issue was on this page. <?php echo "$customer_project_id"; ?> <b>Company Name: </b><?php echo "$company_name"; ?><br /> <b>Contact Name: </b><?php echo "$customer_fname"; ?> <?php echo "$customer_lname"; ?><br /> <b>Address: </b><?php echo "$customer_address"; ?><br /> <b>City, State, Zip: </b><?php echo "$customer_city"; ?>, <?php echo "$customer_state"; ?> <?php echo "$customer_zip"; ?><br /> <b>Email: </b><?php echo "$customer_email"; ?><br /> <b>Phone: </b><?php echo "$customer_phone"; ?><br /> <b>Fax: </b><?php echo "$customer_fax"; ?><br /> <b>Preferred Method of Contact: </b><?php echo "$cust_pre_meth_contact"; ?> </p> </div> </div> <div id="general_information_section"> <a href="#" onclick="return false" onmousedown="javascript:toggleSlideBox('general_infoBox');">General Information</a> <div class="hiddenDiv" id="general_infoBox" style="border:#FFF 2px solid; width:553px;"> <p>Please click the button below to edit the customer's general information.<br /> <input name="edit_general_info" onclick="edit_general_info()" type="button" value="Edit General Information"/> </p> </div> </div> <div id="billing_information_section"> <a href="#" onclick="return false" onmousedown="javascript:toggleSlideBox('billing_infoBox');">Billing Information</a> <div class="hiddenDiv" id="billing_infoBox" style="border:#FFF 2px solid; width:553px;"> <p>Please click the button below to edit the customer's billing information.<br /> <input name="edit_billing_info" onclick="edit_billing_info()" type="button" value="Edit Billing Information"/> </p> </div> </div> <div id="facility_information_section"> <a href="#" onclick="return false" onmousedown="javascript:toggleSlideBox('facility_infoBox');">Facility Information</a> <div class="hiddenDiv" id="facility_infoBox" style="border:#FFF 2px solid; width:553px;"> <p>Please click the button below to edit the customer's facility information.<br /> <input name="edit_facility_info" onclick="edit_facility_info()" type="button" value="Edit Facility Information"/> </p> </div> </div> <div id="product_needs_information_section"> <a href="#" onclick="return false" onmousedown="javascript:toggleSlideBox('product_needs_infoBox');">Product Needs Information</a> <div class="hiddenDiv" id="product_needs_infoBox" style="border:#FFF 2px solid; width:553px;"> <p>Please click the button below to edit the customer's product needs information.<br /> <input name="edit_product_needs_info" onclick="edit_product_needs_info()" type="button" value="Edit Product Needs Information"/> </p> </div> </div> </div> </div> </div> </div> <div id="right_nav"> <div id="rightnav_header"></div> <div id="rightnav_bdy"> <div id="rightnav_bdy_content"> <div id="rightnav_proj_status"> <p> All Current Associated Project Statuses </p> </div> <hr /> <div id="rightnav_alerts"> <p> Any associated alerts sent so far </p> </div> </div> </div> </div> </div> <!--PAGE CONTAINER--> <div id="footer"></div> </div> </body> </html> The issue is that each of these ID echo statements (cid being customer id, sid being staff id, and pid being project id) echoes something. CID echoes correctly, SID does as well. For some reason, PID only echoes the last project ID that was entered for that particular user. So for example, if I add a project to a user and im staff it would be like this: Staff ID = my Staff ID = 1 Customer ID = customer I am currently working on = 11 (in this case...just a random number for example sake) Project ID = the current month number (no zeroes)-00(current customer id being worked on)-0(current project ID from table) = 3-0011-042 If our example is saying that the latest addition is 3-0011-042, and I click on project 3-0011-038, for some reason (EVEN THOUGH MY WEB LINK HAS THE CORRECT PID which is 3-0011-038) it only echoes the last PID entered in the table. Its almost like its completely ignoring what I have in my address bar and looks directly at my tables latest entry....this has really screwed with my brainnnn!!! I can't seem to figure it out for the life of me. I don't even know how I could run a $_GET function and not get what I am asking for.....crazy. Please help guys!!!! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=352984.0 Hello, ive got the right output from the code below, only my mysql query doesnt seem to be working as it should. Im not too great with mysql so please any help or suggestions would be great. I have tried the code but when I check my database nothing has been inserted. !?! Code: [Select] <?php include('db.php'); include('func.php'); ?><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Chained Select Boxes using PHP, MySQL and jQuery</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> </head> <body> <p> <form action="" method="post"> Name: <input type="text" name="Name" /><br /> Phone: <input type="text" name="Phone" /><br /> Email: <input type="text" name="Email" /><br /> Postcode: <input type="text" name="Postcode" /><br /> Web Address: <input type="text" name="Website" /><br /><br /> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $tier_two = $_POST['Subtype']; echo "You selected "; echo $drop." & ".$tier_two; } $Name = $_POST["Name"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $Postcode = $_POST["Postcode"]; $Website = $_POST["Website"]; echo "<br>"; echo $Name; echo "<br>"; echo $Website; mysql_query ("INSERT INTO business (Name, Type, Subtype, Phone, Email, Postcode, Web Address) VALUES ('$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website')"); ?> Im not sure it makes a difference but, I am adding data into each column of my database with the exception of the 1st column named 'ID' which is set to auto_increment. I keep trying to install every wordpress, or php web server software I can find, the lastest being WAMP. Nothing ever works. I feel like a complete retard here being that I can't even set up a stupid program, to be ABLE to program myself. Everything I install gives me a 404 not found error when I try to load the admin index page to a browser. I honestly have no friggn clue what is going on, I know syntax pretty decently for a lot of these languages, but as far as setting them up, I might as well just shoot myself. I know they can't make it any easier with these step by step tutorials, but it just doesn't seem to work on my comp.
When signed in as a user, the username shows up on the top right page. Then, if I click a particular product of another user it changes the session variable to that of the other user. Why would this happen? It's really odd. Im having this error and have the not even the slightest clue on how to solve it... Code: [Select] Notice: Undefined offset: 2 in C:\wamp\www\updat5.php on line 146 <?php $picture = array(); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $picture = array(); switch ($row['icon']) { case 1: $picture[$id] = '<img src="img/apple.gif" title="apple" alt="apple" />'; echo $picture[$id]; break; case 2: $picture[$id] = '<img src="img/banana.gif" title="banana" alt="banana" />'; echo $picture[$id]; break; case 3: $picture[$id] = '<img src="img/orange.gif" title="orange" alt="orange" />'; echo $picture[$id]; break; default: $picture[$id] = ''; echo $row['icon'] . " is something other than 1 2 or 3"; break; } } ?> <hr> <?php echo $picture[2]; ?> And line 146 is: echo $picture[2]; My next post will be the full code if needed incase the error I have currently cant be fixed with the current snippet/block i posted. Can anyone tell me why this is not INSERTing? My array data is coming out just fine.. I've tried everything I can think of and cannot get anything to insert.. Ahhhh! <?php $query = "SELECT RegionID, City FROM geo_cities WHERE RegionID='135'"; $results = mysqli_query($cxn, $query); $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($row = mysqli_fetch_array($results)) { $insert_city_query = "INSERT INTO all_illinois SET state_id=$row[RegionID], city_name=$row[City] WHERE id = null" or mysqli_error(); $insert = mysqli_query($cxn, $insert_city_query); if (!$insert) { echo "INSERT is NOT working!"; exit(); } echo $row['City'] . "<br />"; echo "<pre>"; echo print_r($row); echo "</pre>"; } //while ($rows = mysqli_fetch_array($results)) } //if (mysqli_num_rows($results)) else { echo "No results to get!"; } ?> Here is my all_illinois INSERT table structu CREATE TABLE IF NOT EXISTS `all_illinois` ( `state_id` varchar(255) NOT NULL, `city_name` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Here is my source table geo_cities structu CREATE TABLE IF NOT EXISTS `1` ( `CityId` varchar(255) NOT NULL, `CountryID` varchar(255) NOT NULL, `RegionID` varchar(255) NOT NULL, `City` varchar(255) NOT NULL, `Latitude` varchar(255) NOT NULL, `Longitude` varchar(255) NOT NULL, `TimeZone` varchar(255) NOT NULL, `DmaId` varchar(255) NOT NULL, `Code` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; hi i need help an idea how can i separate members from admins since i dont know how to create login form i used tutorial ( http://www.youtube.com/watch?v=4oSCuEtxRK8 ) (its session login form only that i made it work other tutorials wre too old or something) how what i want to do is separate members and admins because admin need more rights to do now i have idea but dont know will it work like that what i want to do is create additional row in table named it flag and create 0 (inactive user) 1 (member) 2 (admin) will that work? and how can i create different navigation bars for users and admins? do you recommend that i use different folders to create it or just script based on session and flag? Hello guys, Is there on web any updated tutorial on how can I add Facebook login on my simple php login script? How to add the ability to login with username or email for login?
<?php ob_start(); include('../header.php'); include_once("../db_connect.php"); session_start(); if(isset($_SESSION['user_id'])!="") { header("Location: ../dashboard"); } if (isset($_POST['login'])) { $email = mysqli_real_escape_string($conn, $_POST['email']); $password = mysqli_real_escape_string($conn, $_POST['password']); $result = mysqli_query($conn, "SELECT * FROM users WHERE email = '" . $email. "' and pass = '" . md5($password). "'"); if ($row = mysqli_fetch_array($result)) { $_SESSION['user_id'] = $row['uid']; $_SESSION['user_name'] = $row['user']; $_SESSION['user_email'] = $row['email']; header("Location: ../dashboard"); } else { $error_message = "Incorrect Email or Password!!!"; } } ?>
Hi guys, Can anyone assist me. I am trying to create a login for admin and user (if user not a member click register link) below is my code: But whenever I enter the value as: Username: admin Password:123 - I got an error message "That user does not exist!" Any suggestion and help would be appreciated. Thanks. login.php <?php //Assigned varibale $error_msg as empty //$error_msg = ""; session_start(); $error_msg = ""; if (isset($_POST['submit'])) { if ($a_username = "admin" && $a_password = "123") { //Define $_POST from form text feilds $username = $_POST['username']; $password = $_POST['password']; //Add some stripslashes $username = stripslashes($username); $password = stripslashes($password); //Check if usernmae and password is good, if it is it will start session if ($username == $a_username && $password == $a_password) { session_start(); $_SESSION['session_logged'] = 'true'; $_SESSION['session_username'] = $username; //Redirect to admin page header("Location: admin_area.php"); } } $username = (isset($_POST['username'])) ? $_POST['username'] : ''; $password = (isset($_POST['password'])) ? $_POST['password'] : ''; if($username && $password) { $connect = mysql_connect("localhost", "root", "") or die ("Couldn't connect!"); mysql_select_db("friendsdb") or die ("Couldn't find the DB"); $query = mysql_query ("SELECT * FROM `user` WHERE username = '$username'"); $numrows = mysql_num_rows($query); if ($numrows != 0){ while ($row = mysql_fetch_array($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } //Check to see if they are match! if ($username == $dbusername && md5($password) == $dbpassword) { header ("Location: user_area.php"); $_SESSION['username'] = $username; } else $error_msg = "Incorrect password!"; //code of login }else $error_msg = "That user does not exist!"; //echo $numrows; } else $error_msg = "Please enter a username and password!"; } ?> <!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=iso-8859-1" /> <title>Login Page</title> </head> <body> <br /> <?php require "header.php"; ?><br /> <div align="center"> <table width="200" border="1"> <?php // If $error_msg not equal to emtpy then display error message if($error_msg!="") echo "<div id=\"error_message\"style=\"color:red; \">$error_msg</div><br />";?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <!--form action="login_a.php" method="post"--> Username: <input type="text" name="username" /><br /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name = "submit" value="Log in" /> </form> <p> </p> Register a <a href="register.php">New User</a> </table> </div> </body> </html> Hi guys. What I want to create is really complicated. Well I have a login system that works with post on an external website. I have my own website, but they do not give me access to the database for security reasons, therefore I have to use their login system to verify my users. What their website does is that it has a post, with username and password. The POST website is lets say "https://www.example.com/login". If login is achieved (i.e. username and password are correct), it will redirect me to "https://www.example.com/login/success" else it will redirect me to "https://www.example.com/login/retry". So I want a PHP script that will do that post, and then according to the redirected website address it will return me TRUE for success, FALSE for not successful login. Any idea?? Thanks Hi I'm trying to do a php website using notepad++ but when I save it and I test it out on a web browser it gives me my coding instead of a form. How do I fix this. Thank you I have a MYSQL Query and when I see the code, I think it would do what I want it to do, also so do my other friends, but it doesn't. What I'm trying to do is basically make a top 10 poster, and select and order the list by the person with the most posts in the table. The table has a field named user, which represents the username. So basically I'm trying to order it by the `user` with the most posts. The problem is that it only displays the first row in the table, which is id:1. Code: [Select] SELECT * FROM `mrsw_adventurer_log` ORDER BY COUNT(`user`) I can't seem to figure it out. Hi there, I have been following this tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql/6 I have everything working, but I am a little confused when it comes to the "Links for Single Records" part. The following code snippet is what I am using to display the data that is in the database on the page after it is inserted, inside of a table. It is working fine, but the "edit" link just brings up a blank page, that has my edit code on it. Code: [Select] <table border="1" bordercolor="#000000" cellspacing="2" cellpadding="10"> <tr> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Name</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">E-Mail</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Age</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Gender</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Location</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Home Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Other Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Best Time to Reach</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Referrer</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Options</font></th> </tr> <? $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $email=mysql_result($result,$i,"email"); $age=mysql_result($result,$i,"age"); $gender=mysql_result($result,$i,"gender"); $location=mysql_result($result,$i,"location"); $homephone=mysql_result($result,$i,"homephone"); $otherphone=mysql_result($result,$i,"otherphone"); $besttime=mysql_result($result,$i,"besttime"); $referrer=mysql_result($result,$i,"referrer"); ?> <tr> <td><font class="lead_txt"><? echo $name; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $email; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $age; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $gender; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $location; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $homephone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $otherphone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $besttime; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $referrer; ?></font></td> <td bgcolor="#01337f""><a href="db_edit.php?id=$id"><img src="edit.png" width="25" height="25" alt="Edit"></a> <a href=""><img src="delete.png" width="25" height="25" alt="Delete"></a> <a href=""><img src="email.png" width="25" height="25" alt="E-Mail"></a></td> </tr> Any ideas? Thanks in advance!! Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>"; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END This shows all my subforums on my forum, but 1 problem, if I try to seperate them, like let's say with a "comma" by using: Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END It will show the , BEFORE the link? so weird, here is the function: Code: [Select] $forum_data['subforums'] = "<br> <span class=desc4>Subforums:</span> "; foreach($this->children[ $forum_data['id'] ] as $idx => $data) { //-------------------------------------- // Check permissions... //-------------------------------------- if ( $std->check_perms($data['read_perms']) != TRUE ) { continue; } // Do the news stuff first if (isset($data['last_title']) and $data['last_id'] != "") { if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) ) { $this->news_topic_id = $data['last_id']; $this->news_forum_id = $data['id']; $this->news_title = $data['last_title']; } } if ($data['last_post'] > $newest['last_post']) { //Subforum last_title? $newest['last_post'] = $data['last_post']; $newest['fid'] = $data['id']; //$newest['id'] = $data['id']; $newest['last_id'] = $data['last_id']; $newest['last_title'] = $data['last_title']; $newest['password'] = $data['password']; $newest['last_poster_id'] = $data['last_poster_id']; $newest['last_poster_name'] = $data['last_poster_name']; $newest['status'] = $data['status']; $newest['star'] = $data['star']; } $newest['posts'] += $data['posts']; $newest['topics'] += $data['topics']; $printed_children++; //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END } How can I make it so it doesn't show the , before the FIRST link on that subforums variable, but only after every link and beyond? Okay I got it working by moving it ontop Code: [Select] $forum_data['subforums'] .= "<a href=?z={$data[id]}>{$data['name']}</a>, "; //mod_KaLiTe_Subforums END $printed_children++; but now it shows the , after the last link, how do I make it so it doesn't show the comma for the last child? |