Jump to content

MrScabby

Members
  • Posts

    19
  • Joined

  • Last visited

  • Days Won

    1

MrScabby last won the day on May 28 2019

MrScabby had the most liked content!

MrScabby's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. One last request if I may, and thankyou for the above advice. I have now found this site to work from but on this occasion I want to make sure that Im singing off the same song sheet as everyone else. Is this up-to-date and a good starting point for a (usable) website login system for my site? just want to be sure I do not repeat the same mistake,,, http://www.ineedtutorials.com/code/php/complete-advanced-login-member-system-php-tutorial
  2. lol, I did warn you it was old but it does happen to have what a lot don't - its easy to understand and gets the structure across Yes by the way, CHAR(16) and I created it myself as one of the tests to see if it needed a pre-defined database. Your going to say its wrong now aren't you! oh well at least Im trying, Dont suppose you can suggest a more up to date site can you, one without a learning curve like Beaches Brook!
  3. The site Im using is here but I will say the code is old and basic and has no protection/sanitation, but it is it's simplicity which makes it clearer to follow if you have not done it before which is where I am at the moment.... Managing Users with PHP Sessions and MySQL Ive downloaded the sample code and altered the parts to work on my server. I have everything working except or some reason I cannot login. I've checked everything is working including seeing the tables in the database to see that they are being created correctly. The only area I cannot check is the password because the encryption does not allow me to check it, if you see my point. I have narrowed the issue down to this one statement contained in the accesscontrol.php which I have repeated below, <?php // accesscontrol.php include_once 'common.php'; include_once 'db.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; echo "Data Variables" . " uid =" . $uid . " pwd =" . $pwd; if(!isset($uid)) { ?> <!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> <title> Please Log In for Access </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Login Required </h1> <p>You must log in to access this area of the site. If you are not a registered user, <a href="signup.php">click here</a> to sign up for instant access!</p> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> User ID: <input type="text" name="uid" size="8" /><br /><br /> Password: <input type="password" name="pwd" SIZE="8" /><br /><br /> <input type="submit" value="Log in" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; echo "Session Variables: uid=" . $_SESSION['uid'] . " pwd=" . $_SESSION['pwd']; dbConnect("cl42-daystaff"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = PASSWORD('$pwd')"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact xxxxxx@xxx.com.'); } echo "Num of rows =" . mysql_num_rows($result); if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!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> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Access Denied </h1> <p>Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To register for instant access, click <a href="signup.php">here</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); ?>
  4. Hi all Im having a problem with this MySQL statement, Im trying to set up a login system following instructions from another site All is working well except it fails when I try to log in, Why would this NOT work $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = PASSWORD('$pwd')"; when this does $sql = "SELECT * FROM user WHERE userid = '$uid' "; It would seem this part is not functioning correctly AND password = PASSWORD('$pwd') Just for ref this is the insert statement used to create a new user, working ok! $sql = "INSERT INTO user SET userid = '$_POST[newid]', password = PASSWORD('$newpass'), fullname = '$_POST[newname]', email = '$_POST[newemail]', notes = '$_POST[newnotes]'"; Specs:- Server: Localhost via UNIX socket Server type: MySQL Server version: 5.5.42 - MySQL Community Server (GPL) Apache/2.4.10 (Unix) Database client version: libmysql - mysqlnd 5.0.8-dev PHP extension: mysqli Version information: 4.0.7, latest stable version: 4.4.12 PHP version 5.3
  5. Thank you for giving me a concise answer - I understand now and that answers many a frustrating hour or three pulling my hair out because what little clues I had to go on had no logical path I could follow to solve, you saying that now explains why there is no trail to follow. I really should have that in mind by now but trying to get javascript, php and HTML to hold together and talk to each other is a test of character I think, Is there some coffee club I can join when I've passed my initiation ceremony? thanks
  6. lol, worst possible reply but thanks anyway, lol Timestamp: 10/07/2015 03:03:13 Error: SyntaxError: expected expression, got '<' Line: 23, Column: 43 Source Code: outputBOXelement.value = <?php echo $outp; ?>;
  7. I'm just trying to access the data contained in $outp, this contains a single record/row from a SQL database built into a string. Everytime I try to use some php script it triggers the syntax error and fails but the main problems Im encountering is getting some information about what went wrong. take the above, lets say the php needs double quotes and because I missed them it fails. How do I get information to use as a clue to the fault? the methods I have used so far are the error console in firefox, if this pulls up an error you can click the link to see some of the output. so this is ok I also check the syntax (as in this case) with an online checker. but after that Im stuck, if none of the above lists a message or error it just doesn't work and u have no clue where to start
  8. Hi all I know this is one of those obvious things that you just cannot see when its patently obvious .....but! Why does this cause a syntax error? 1 outputBOXelement.innerHTML = <?php echo $outp; ?> =============================^ SyntaxError: syntax error output via http://www.javascriptlint.com/online_lint.php
  9. Thanks for that, Yes requinex, AJAX does sound the ticket. I was going in circles trying to work out which method to use. When you start looking you get the feeling people have their own methods they prefer, I have read tricks using all sorts of coding techniques and in the end all it served was to confuse me... I'm reading right now, lets hope there isn't too much of a learning curve...
  10. Hi again all, I think I'm going round in circles here trying to chose a method to populate a form with a chosen name. I also think with a well crafted reply could put me right and save more lost hours. Im new to this area of coding and you could say not practised. So with a few months till my next module I thought I would reaffirm my current knowledge by launching into a project. Lol, even the smallest of ideas can involve hours and hours of commitment. I think though in my current problem Im lost because there are so many answers and I cannot decide what or which to chose. The specification is creating the registration part of a website, New User, Edit User, Delete User - sounds simple but Im trying to make it work similar to a web app so I would expect a lot of interaction between the server and the client - There is a comboBox at the top populated with the 'profile_name' information. I want the user to select a name and the form underneath the combobox to fill with all the other information. as this is only a simple practice I only need a simple form with 5 or so fields per row profile_name,profile_alias,profile_email,profile_phone,profile_mobile in a table called 'profiles'. So Im thinking I will need an 'onchanged' event so when a new name is selected I can call a javascript function to go get the info for the rest of the form, this will be returned by the php script and I then populate the form. And this is where I get stuck - As I re-write the keywords to dig out more articles about moving variables between server and client and vice-versa, the more work I dig up for myself. I mean what is the best/easiest to do? I would have thought something like this would have a simple method or function alas no. Ajax, Json, Cookies, Headers, XML, ??? and so on. I ended up confused and looking at months of learning just to send/receive variables. I think asking is the best thing here, On a different note, do I really have to rewrite the entire form everytime someone selects a different name from the combobox? It would be best if the form remained static and the content of the html boxes changed. Is this possible? and do I have my understanding of the relationship between client and php server wrong here? I was thinking the server had some control over data but if I echo the php results as said in some of the articles then my form is refreshed with a blank screen. I suppose I could change the php to rebuild the form but am I again choosing the hardest method? Thanks in advance, Phil
  11. sorry for not coming right back to you, I was so tired I had to sleep - when I returned to it in the morning I solved it. lol ain't it always the same, ...and so you do not think I messed you about and way of a thanks I will explain HOW the next day people seem to get their eureka moment. As I recently discovered how it works and Im so amazed with it I want to tell folks. Im studying Open University at the moment and I noticed something kept on happening, I would read a question - think about it, know damn well I had read it and at the time I read it I understood it but for the life of me I couldn't work out the problem. Try, try and try again there was no way you was going to get the answer - it was almost like I was searching in the wrong draw of a filing cabinet. In the end I would get pissed with the whole thing and take the dog for a walk or go into the garden and weed - any job that doesn't require thinking.... when I came in and read the question again BINGO! it would drop into place - It was almost as if I WAS thinking about it all the time even though to me I had thrown all thoughts about the issue out of my mind (that part of it is important, do NOT think about it) Later in the week I came across a video on YouTube about 'Super conciousness' and it was the very thing that I had found out myself. apparently it works like this You consist of 10% of your brain, that is the cognitive processing goes on in the 10% of our brains. the other 90% is a bit of a mystery but they think its mostly autonomous functions like walking, moving, heart, lungs etc The 10% doesn't have a very good access to memory, it can recollect recent memories but if you take in a large amount of information in a short time span then a lot of short term memory is shunted into long term memory. The 90% has VERY limited cognitive functions but one thing it can do and do very well is memory retrieval, And apparently it is very very good at this. so this is how you use it. You read your question, the answer or methodology needs to be already in your head ie you read it and understood it. You go do some menial task for an hour, while your doing this task your brain is searching for any relevant memories and pulling them into your short term memory. You return to the question and BINGO! you get your answer. Try it - I have on multiple occasions and it really does work. YouTube the term 'Super Conciousness' oh and thanks dude for your time.
  12. Can I use the DOM to move to the correct placement? (or someother method) I still seem to be having problems putting the output into the combobox,
  13. Can you explain how the selection process works for the combobox? Ok so we are building a string with the correct instructions for populating the combobox, So what do I have to do with the string - assuming the string has been built correctly. does simply echo'ing the string execute the string, eg select combobox, add options one by one,,..... the last line is echo $selectbox, this appears to work in that the string when echoed does list out the names as required just not where we need them, ie it does the names on the backdrop. However it seems to me that the selection of the combobox is not working>... don't quite understand the relationships here .... Just an idea,,,,,, Could this happen when the php is executed PRIOR to the combobox's construction..... Am I calling the PHP script too early......hmmm
  14. ok done, I now have some output only it's on the form background, the output is correct, ie Bugs Bunny Donald Duck Mickey Mouse only its wrote on the forms background not the combobox whos name='selectedUser' ghads, life just shouldn't be this difficult.......................mind it is the very first time I have done this so maybe it needs to be painful eh!
×
×
  • 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.