Jump to content

xtopolis

Members
  • Posts

    1,422
  • Joined

Everything posted by xtopolis

  1. Use mysql to order by a certain column, then set the method to descending. "SELECT * FROM Table ORDER BY somecolumn DESC";
  2. Without seeing if this is a page in itself or not, I would say remove the whitespace. Basically make the file like this: <? session_start(); // Check if session is not registered , redirect back to main page. if(!isset($_SESSION['myusername'])){ header("location:index.php"); } else { echo"Login Successful"; } ?> Notice there is no blank line before the <? tag. also I just moved the comment below the session. However if that code is actually below other code in the page, we would need to see that. Header errors are almost always caused by unintended whitespace being show before php parses the script.
  3. Hey, So I've got it to work on my end under similar circumstances. Obviously you didn't send me all of your code, so you will need to fill in my stuff into yours and make it work. Change this stuff: 1)Make params like this: var params = "user=" + user + "&pass=" + pass; There is no preceeding ?, and it must match what the check.php expects (user & pass); 2)return false; I'm not sure if you're doing this because it's not in your login function, but might be elsewhere. But it's a good idea to add to the form tag like this: <form onsubmit="return login()">. And then in the last part of your login function have: return false; This stops the form from doing anything on click other than run the login() function. 3)Database verification. I hard coded values and it seems to work. I would strongly recommend you do your query as a "SELECT COUNT(*) as numrows WHERE username='$user' AND pass='$pass'"; Then it would be the same mysql stuff... $result = mysql_query($sql); $row=mysql_fetch_array($result). if($row['numrows'] != 1) { echo 'Incorrect login.';}else{ echo 'Success';} The only reason I stress the database thing is so that you make sure you have only ONE match for security purpose. Obviously this is up to you, but it's good form and practice IMO. The code I have, it's slightly changed from yours, but commented. index.html <html> <head> <script type="text/javascript" src="http://www.xtopolis.com/z_phpfreaks/simplelogin/ajax.js"></script> <script type="text/javascript"> http = new newXHRO();//### I used my own XMLHttpRequestObject, linked off my site, feel free to copy function login() { document.getElementById('login_response').innerHTML = "Verifying user..." var user = encodeURI(document.getElementById('user').value); var pass = encodeURI(document.getElementById('pass').value); var url = "check.php"; //####CHANGED from include/check.php, change it back var params = "user=" + user + "&pass=" + pass; http.open("POST", url, true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var response = http.responseText; document.getElementById('login_response').innerHTML = ''+response+ ''; } } http.send(params); return false; //####ADDITION } //function </script> </head> <body> <form onsubmit="return login()"><!-- ### NOTICE THE RETURN HERE--> <label>Username</label><input type="text" name="user" id="user" /><br /> <label>Password</label><input type="password" name="pass" id="pass" /><br /> <input type="submit" value="Login" /> </form> <div id="login_response"> </div> </body> </html> check.php <?php $user = $_POST['user'];//mysql_real_escape_string($_POST['user']); $pass = md5($_POST['pass']); /* $sql = "SELECT * FROM admin WHERE username='$user' && password='$pass'"; $result = mysql_query($sql); $row=mysql_fetch_array($result); */ //## HARD CODED FOR TEST $row['username'] = 'xtops'; $row['password'] = '1a1dc91c907325c69271ddf0c944bc72'; if($row['username'] == $user && $row['password'] == $pass) { echo 'you are logged in.'; } else{ echo 'incorrect login.'; } ?> If you still have trouble, let me know.
  4. While it's never a good idea to send passwords / userinfo in plain text, it won't make much of a difference while you get started. If anything you can change your server side verification to be non standard[meaning, instead of using the assumed MD5, use another encrypt, or add salt] So, from your form you should send the username and password. From there , verify that javascript picks those values up correctly. (Call your login function, alert username, alert password. From there, create your params var and alert that as well to make sure it's sending the url addon as expected. What may be wrong is your params string. I'm not too familiar with javascript including vars in strings, so you might do this: (ALSO, you might add a preceding ? to your string) var params = "?user=" + user + "&pass=" + pass; alert(params) //check that it is as expected Try that and let me know how it goes.
  5. Sure. Send me a simple version that includes the php verification, and ajax/login page including the javascript used so I can see and debug it. For the verification I will just hard code vals, so no need for database stuff atm.
  6. Hmm, it's hard to decipher the pieces. If you could, post the 2 complete files, or 3 so I can debug it.
  7. Do you have this working with just php? IE: make the form submit to the php page, don't use ajax at all, and see if you can get that to work. If you do, start out by sending the values via ajax and make sure that the sent values are received as expected (ie: alert(username)/password and see that javascript is sending them right. After you do these, tell us what specifically is not working.. verification, or ajax?
  8. http://www.cssplay.co.uk/menus/flyoutt.html
  9. anchor tag name attributes are case sensitive. Change <a name="Email"> to <a name="email">.
  10. I looked at your code and found that the thing that it doesn't like seems to lie in the first <td> that contains your avatar. If you take away the <br /> and the <p>s it works like you seem to want it to. If you add <br />s to the 2nd <td> for the message portion of it, it pushes it down to the bottom. Basically, it's right by just having the bottom portion be 2 <p>s float left and right, but for some reason the spacing on the <td> with the avatar is making the 2nd one act weird. I can't work on this anymore atm, but I'd be happy to take a look at it tomorrow. At least now you know what's causing the spacing thing. Play around with it, let me know what you get. Sorry I couldn't help more atm.
  11. Hey Nexy, So I didn't have a login to your forum so I couldn't see the rest of the code, so the stuff I post below might not work with the rest of your styles. Anyway, the main thing I did was change: - div[pm_msgans] to contain 2 <p> tags instead of a div inside a div., then I floated one of them to the left, and the other to the right. - your message div has a margin-bottom: .4em, change that to padding-bottom .4em (fixes ie small spacing at bottom bug) Note: I've only tested this in FF3, and IE7 Here's the code to look through, obviously only take what you need to fix yours. Let me know if it works. <html> <head> <style type="text/css"> * {margin: 0; padding: 0;} td { vertical-align: top; cellspacing: 0; cellpadding: 0;} td.avatars { border: 1px solid black; width: 200px;} td.msgbody { vertical-align: top; width: 500px; border: 1px solid black;} p.pm_msgquote {float: left;} p.pm_msgrep { float: right;} div.pm_msgcont { text-align: left; padding-bottom: .6em;} </style> <body> <table> <tr> <td class="avatars"> <div class='pm_msgbody'> <p>Test</p> Avatar <p>Gold | Rep</p> </div><!--pm_msgbody--> </td> <!-- message section --> <td class="msgbody"> <div class='pm_msgtext'> <div style='border-bottom: 1px solid #000; margin: 0'> PM Topic --- Date </div> <div class="pm_msgcont">Message Message Messagege </div> <div class='pm_msgans'> <p class="pm_msgquote">Quote PM | Ping Shoutbox</p> <p class='pm_msgrep'> Delete | Reply </p> </div><!-- message ans--> </div><!-- pm _msgtext--> </td><!-- msg--> </tr> </table> </body> </head> </html>
  12. Not sure what you mean, but there is no such thing as "design":inline. the word is "display":inline. There is also a "word-wrap" attribute. I think the values are word-wrap:break-word; and word-wrap: normal; Look it up.
  13. If you view their source, you can see the code they use. When you submit, it calls a javascript function to check the values to see if they are what is expected. If they aren't it uses javascript to change their CSS values, such as input.style.border = "1px solid red"; for the wrong ones. Then they use an onclick event to popup a div that has the appropriate error message (Stored at the bottom of their script). CSS, hiding/showing divs, all manipulated by javascript.
  14. What version of IE? IE 7 and FF3 look the same to me. If it's still a problem, post some RELEVANT code, not your whole thing.
  15. You may be able to look at the global var: $_SERVER['REQUEST_URI']; and from there do some string manipulation to find out what the page was called. $from = $_SERVER['REQUEST_URI']; Although, I'm not sure how this works, I rarely use it. Doing a small search I found this though: http://www.dezinerfolio.com/2008/01/09/back-to-previous-page-php/ You could store the current page in a var, so when you go to the next one you'd know where you were last, if it was in your pages with sessions.
  16. I don't know either =/ . If you put something like index.html in that folder and nothing shows up, it's not looking for index.* files, which means it's not working correctly. Unfortunately my server knowledge is limited.
  17. hassank1 - 1)The wrapper is not necessary. I just have a habit of wrapping my code. 2)Does it not work AFTER you changed what I had, or did it not work from the get go? And in what version of FF? I was at work when I wrote that using FF2, IE6, and it seemed to be fine. At home in FF3 and IE7, it works well, but IE7 has right side padding issues like in your pics. 3) Are you going to use pictures of a set size? ie: 32x32 pix ONLY, or will they be variable sized? If so, you will need to set it up to accommodate the largest size images, and change your widths accordingly. (Like the comment I left in the css file)
  18. Does it have a parser for it? like in .htaccess, something that looks like AddType application/x-httpd-php .php or w/e?
  19. CSS" div#newsletter_container { float: left; width: 364px; height:143px; background-image:url('images/15.gif'); } div#welcome_container { margin-left: 365px; height:143px; background-image:url('images/17.gif'); } HTML: <div id="newsletter_container"> Text </div> <div id="welcome_container"> Text 2 </div> Notice the first side (left side div) floats left with a fixed width. The right side div has a left margin of the left divs width +a few pixels for borders etc.
  20. i3lack, tell us this. Was the site hosted on a computer that you own, in your house or w/e? And now you've paid for your website to be hosted on someone else's server, like godaddy, 1and1, etc? You scripts all have the same problem, so there is no need to spread out the questions. You have moved the files from somewhere where they no longer appear in the same way. Firstly, the mysql error we cannot help you with. It's telling you the information you supplied is wrong. I'm guessing it's the 'localhost' pointer. You need to fix that on your own. The rest is simply saying "I can't find this file"[failed to open steam]. It's telling you where it's looking for it, so find it and/or put it there. YOU NEED TO READ YOUR OWN ERROR MESSAGES BEFORE POSTING ANY MORE QUESTIONS, IMO
  21. You are dividing by zero on line 4 of index.php Your mysql access seems to be wrong now, meaning the username/pass/etc you coded are no longer valid. I see grandma@localhost which I think means you had it hosted on a machine of your own? Post some code, but that math error, and the access error are the main ones. The other mysqls might clear up if you fix the first one regarding your access.
  22. In your CSS add these on to the existing rules: body { text-align: center; } #container { text-align: left; } Enjoy.
  23. Give them a name and id? name="list[]" for PHP, and id="list" for javascript? I'm 99% sure you can make your funcs get elements by id or something similar. edit: or possibly what you already have would work if you use the id like I mentioned above
  24. Save your page in a different encoding. When you do file->save as: At the bottom choose: Encoding-> UTF-8 [instead of the default ANSI] However, I do not know if there are any downsides to this. This is simply what I did when I wished to display Russian chars on a site I helped build. If there are any downsides, I would like to hear them so I can change as well.
  25. I made something similar. Thanks for the challenge. This may not be exactly what you're looking for, but it's definitely tweakable to get there. Pretty close eh? Enjoy. index.html <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="index.css" /> </head> <body> <div id="Wrapper"> <div id="r_g"> <h3 id="rg">Recent Groups</h3> <div class="floatright"><img src="" class="rgThumbs"><br />I am a caption.</div> <div class="floatright"><img src="" class="rgThumbs"><br />No wait, I'm a caption.</div> <div class="floatright"><img src="" class="rgThumbs"><br />This word is certainly a little loooongerrrrr.</div> <p style="clear: both;"> </p> <div class="floatright"><img src="" class="rgThumbs"><br />Luckily most captions are small.</div> <div class="floatright"><img src="" class="rgThumbs"><br />You can always make the box wider.</div> <div class="floatright"><img src="" class="rgThumbs"><br />To accomdate bigger captions.</div> <p style="clear: both;"> </p> <!-- THIS TRAILING <P> IS IMPORTANT, MAKES THE RECENT GROUP BOX EXTEND IN HEIGHT TO MATCH THE IMAGES--> </div> </div><!-- wrapper --> </body> </html> index.css * { margin: 0; padding: 0;} html,body { width: 100%; height: 100%;} div#wrapper { width: 85%; margin: 0 auto;} div#r_g { right: 0; border: 1px solid purple; background-color: rgb(226,226,226); width: 300px; /*This size needs to match the (3 images) X .floatright width + (3images) X [(2) X .floatright padding for each side]*/ /* ie: 80 * 3 = 240 => + 3 * (2 * 10) = 300 totalpx*/ } h3#rg { padding: 3px; padding-bottom: 5px; color: white; background-color: purple; font-size: 8pt; font-family: 'Verdana'; margin-bottom: 10px; font-weight: normal; } .floatright { float: left; width: 80px; padding: 10px; padding-bottom: 0px; font-size: 10px; font-family: 'Tahoma', monospace; text-align: center; } img.rgThumbs { border: 1px solid black; height: 40px; width: 40px; margin-bottom: 5px; }
×
×
  • 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.