Jump to content

Ricky55

Members
  • Posts

    100
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Ricky55

  1. Thanks mate, really appreciate this!
  2. Hi, I have the code below that using for a simple login system (security not a concern at all) This code works but it now has around ten if statements (not included them all for clarity), would this be best written as a switch statement? if so can you help me code it. I can write basic switch statements but I don't know how to match two cases. The login and the password. If a switch statement isn't the best option can you suggest what is and perhaps give me an example? Thanks guys! The code: <?php session_start(); $is_ajax = $_REQUEST['is_ajax']; if(isset($is_ajax) && $is_ajax) { $username = $_REQUEST['username']; $password = $_REQUEST['password']; if($username == 'richard' && $password == '123') { $_SESSION['isLoggedIn'] = true; echo ("login-richard"); } if($username == 'john' && $password == '456') { $_SESSION['isLoggedIn'] = true; echo ("login-john"); } } ?>
  3. Hi Guys Struggling to get this working. This code appears on my page-blog.php When the links are clicked the url changes to /page/2/ etc but the posts themselves don’t change. I have some very similar code in my single.php and its working fine. My code is below, what am I doing wrong? <section role="main"> <?php $page = get_page_by_title('the blog'); $content = apply_filters('the_content', $page->post_content); echo $content; ?> <?php $blog_posts = new WP_Query(); $blog_posts->query('showposts=5'); if ( $blog_posts->have_posts() ) : while ( $blog_posts->have_posts() ) : $blog_posts->the_post(); ?> <article> <?php the_title(); ?> </article> <?php endwhile; ?> <nav id="post-nav"> <span class="prev"><?php next_posts_link( '← View Older Posts', $blog_posts->max_num_pages ); ?></span> <?php previous_posts_link('<span class="next">' .( 'View more Recent Posts →' ). '</span>'); ?> </nav> <?php else: ?> <p>Sorry it looks like you need to add some posts to this blog!</p> <?php endif; wp_reset_query(); ?> </section>
  4. Thanks man. I checked the server logs and they were reporting a fatal error. It turned out that the files were becoming corrupt in the download / upload process. I think this is down to the odd characters some of the encrypted code uses. A way around this is to use binary mode in your FTP client or in my case I used the server to create a zip file back up that I uploaded to the new server without uncompressing which worked for me. Thanks for the help. Hope someone finds this useful, I lost quite a few hours to this. Live and learn and all that. Cheers
  5. Hi, A developer who I no longer work with created a site for me a couple of years ago using a shopping cart called StoreSprite. I've been on the StoreSprite website and their forum is no longer allow folks to register so I'm rather stuck. I'm no developer by any means but I've done everything I think of. The cart uses the Zend Optimiser and I've checked that this is installed. I've pointed the site to the new database. When I visit the site all I get is a blank screen, no errors nothing! I've even tried deleting the DB and I still only get this far so its not even getting to this stage. Can you guys suggest anything that I might try? the URL for what its worth is abs-ics.co.uk Cheers in hope.
  6. Thanks mate that appears to have worked. Very much appreciated. Why should this be replaced?
  7. Hi Hopefully one of you guys can help me. My knowledge of PHP is beginner and the Dev that I use is on holiday. Just moved a clients website over to a new host and one part of it is not working. We have these php price calculator scripts that use the function import_request_variables which having turned on error reporting I can see this is what's causing the problem. Having done a quick search online I can see that this is no longer valid in PHP 5.4 is there a quick way of replacing this with something that is valid in PHP 5.4? The line I have is import_request_variables('gp'); Any help as always very much appreciated! Thanks Richard
  8. Thanks mate. I have changed all the links now so they do have the slash. IE9 though on my clients machine fails to find the index.php within a particular folder. Can you think of any reason why this could be happening? He can access every other page of the site apart from this one particular page.
  9. One of my clients has just called to say that he can't access a page on his website. I can access no problem. Its just a static site that uses some PHP. I have a folder to represent each section of the site for example about-us In each folder I have an index.php file. Should my links contain a trailing slash or not? Should I be linking like <a href="/about-us/"></a> or <a href="/about-us"></a> I've tried searching for an answer but no one seems to give a definitive answer. Thanks
  10. Finally got this working via Marcus' suggestion so I just wanted to thank everyone for their patience and help. Cheers guys. Ill probably make the code available on my website for anyone who reads this and thinks this is just what they need. Not trying to plug just trying to be helpful. www.qwerty-design.co.uk
  11. This is not solved, we are on the right track but I still need some help. I've looked into what Marcus suggested but I still need assistance.
  12. hallelujah, hallelujah!!!!!! Yes thats exactly what I want!!! Like I say I'm not sure if what I'm doing is the best way of tackling this but thats exactly what I want in terms of functionality. I'm not using a database though so could I let this AJAX just pick up from my PHP? For example instead of using header ("Location: login.php?error=1"); Could I not send something that AJAX could pick up and then display the message for me? I just don't know how to do this. Thanks Marcus.
  13. I'm getting a bit confused with all this now mate. I think I may be coming at this from the wrong angle. You've seen my page http://www.qwerty-demos.co.uk I need any errors to just show up within my light box rather than opening a new page. From my limited knowledge it seems that I either need to build the PHP logic into the code that I'm showing within the jQuery lightbox so I can just echo out the error or use Ajax so I can detect the error from PHP and just display it in the lightbox but I'm not sure how to do either. I think I might have to get my dev mate to give me a hand. I've spent ages on this and it is working perfectly the page is being protected just as I want I just can't get this damn error to show without loading a new page and breaking my lightbox.
  14. Not sure I follow mate. Perhaps I didn't explain myself properly. I need the error that PHP is generating to be printed in my jQuery window. I know I can write text with jQuery but I can't validate a password client side.
  15. I'm back guys, I know sorry... I've got this working as I want now apart from one tiny aspect. If you go here you can see what I have so far http://www.qwerty-demos.co.uk Login using User: ricky Pass: hello Problem starts when you enter in the incorrect info. in my code I have if(credentials_valid($_POST['username'], $_POST['password'])) { log_in($_POST['username']); header ("Location: ../client-login/"); }else{ header ("Location: login.php?error=1"); exit("You are being redirected"); } The jQuery modal window is just showing login.php which looks like this <div id="login"> <a class="modal_close" href="#">Close Me</a> <form action="_includes/authenticate.php" method="POST"> <label for="username">Username:</label> <input type="text" name="username" size="20" id="username"> <label for="password">Password:</label> <input type="password" name="password" size="20" id="password"> <button type="submit">Submit</button> </form> <?php if($_GET['error'] == '1'): ?> <p>Username and/or password incorrect</p> <?php endif ?> </div> My question is, how do I get the error message "Username and/or password incorrect" to display in my jQuery window and not load login.php as a separate page. Any help will be much appreciated. Cheers guys!
  16. Why isn't this working guys, all seems fine but when I visit my secret page without logging in the content still shows. This is my login code <?php session_start(); $username = 'ddd'; $password = 'xxx'; $after = 'index.php'; ?> <!DOCTYPE html> <html lang=en> <head> <meta charset="utf-8"> <title>My Login Page</title> </head> <body> <form method="post" action=""> <label for="loginUsername">Username:</label> <input type="text" name="username" size="20" id="loginUsername"> <label for="password">Password:</label> <input type="password" name="password" size="20" id="loginPassword"> <button type="submit" name="submit" value="submit" id="submit">Submit</button> </form> <?php if ( ( isset($_POST["username"]) && ($_POST["username"] == $username) ) && ( isset($_POST["password"]) && ($_POST["password"] == $password) ) ) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; $_SESSION['isLoggedIn'] = true; } ?> <?php if ( ( isset($_POST['username']) || ($username == '') ) || ( isset($_POST['password']) || ($password == '') ) ) { print '<p class="login-error">Sorry your username or password was entered incorrectly.</p>'; } ?> </body> </html> This is my secret page code <?php session_start(); if (!isset($_SESSION['isLoggedIn'])) { header("Location: ../index.php"); die; } ?> <a href="logout.php">Logout</a> This is my logout code <?php session_start(); unset($_session['isLoggedIn']); header ("Location: ../index.php"); ?> This is the code I'm using to log users out.
  17. Thanks Christian
  18. Ok thanks guys sorry if I was over complicating the issue. This really is my final question how would l log a user out of the session. My logout button was just going to be a link back to the home page but how would I end the session?
  19. It's not really across multiple pages, it's just a simple client login I'm creating. Users can login from any page of the site but when they have logged in they are just taken to one very simple page that allows them to download marketing assets, images etc. It's doesn't have to secure really I just want users to be redirected to the home page if they try to visit the protected page without logging in first. So is what I have the best way of achieving this?
  20. Is there any other way I could protect this page without using sessions? Can htaccess be used in conjunction with php?
  21. Just one final question guys, does use using sessions have any bearing on performance?
  22. Thanks guys very much appreciate your help.
  23. Thanks mate. Sorry for my lack of knowledge but can I ask How would I start the session from my login page?
  24. Hi very new to PHP. I am wanting to create a very basic client login area. I have some code that I am using in a modal window provided via jQuery which looks nice. I'm wanting the same kind of experience that you get when you log into this website. Security is not an issue for me on this one. So I have my code which works as I want but I now need to protect the secret page its self. I want users to be redirected to my home page if they try to open the URL without going through my login system. How would I achieve this? Would I need to use sessions? Heres my very basic login code. Thanks Richard <?php $username = 'ddd'; $password = 'xxx'; $after = 'http://www.domain/secret-content'; ?> <!DOCTYPE html> <html lang=en> <head> <meta charset="utf-8"> <title>My Login Page</title> </head> <body> <form method="post" action="#"> <label for="loginUsername">Username:</label> <input type="text" name="username" size="20" id="loginUsername"> <label for="password">Password:</label> <input type="password" name="password" size="20" id="loginPassword"> <button type="submit" name="submit" value="submit" id="submit">Submit</button> </form> <?php if ( ( isset($_POST["username"]) && ($_POST["username"] == $username) ) && ( isset($_POST["password"]) && ($_POST["password"] == $password) ) ) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } ?> <?php if ( ( isset($_POST['username']) || ($username == '') ) || ( isset($_POST['password']) || ($password == '') ) ) { print '<p class="login-error">Sorry your username or password was entered incorrectly.</p>'; } ?> </body> </html>
  25. Hi I have a static website that uses some basic PHP, includes, changing titles, conditionally loading CSS and JS files etc but no database. What would be the best way to show this website in four different languages? Just wondered if any of you guys have had to do that without using a CMS. Thanks Richard
×
×
  • 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.