Jump to content

squiblo

Members
  • Posts

    483
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by squiblo

  1. i dont realise how stupid i am sometimes
  2. logout.php <php session_start(); session_destroy(); header("location:index.php"); ?> i get a blank page at logout.php and it does not redirect me to index.php
  3. if someone types in the homepage (index.php) and they are already logged in, i want them to be redirected to their profile (profile.php) but i have got my thinking all wrong and its just stuck in a loop <?php session_start(); if(!isset($_SESSION['myusername'])){ header("location:index.php"); } else { header("location:profile.php"); } exit; ?>
  4. i have swapped them around but its still acting the same <?php session_start(); if(!isset($_SESSION['myusername'])){ header("location:index.php"); exit; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
  5. what am i doing wrong? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php session_start(); if(!isset($_SESSION['myusername'])){ header("location:index.php"); exit; } ?> <html> <head> go to www.squiblo.com/search.php to see the problem
  6. if you know of any good guides please post
  7. i want some pages such as www.squiblo.com/profile.php to only be seen when a user is logged in, but if i type it into the url u can see the contents of the page <? session_start(); if(!$_SESSION['myusername']){ header("location:index.php"); } ?> <html> <body> Login Successful! </body> </html> what is the code so the page can only be seen by people that are currently logged in?
  8. i dont have a clue on where to start with website language, would i have to write it all out loads of times in different languages? the sort of thing i am looking for is shown at www.bebo.com bottom right of the page, i know how to make the menu for it but know nothing about the PHP
  9. this: <div id="wb_text13" style="position:absolute;left:95px;top:197px;width:330px;height:29px;z-index:29" align="center" <font style="font-size:20px" color="#FF0000" face="Arial"><u>Incorrect Username or password!</u></font></div> the color or font does not show
  10. this script works in all other browsers put now Internet Explorer what is the problem?? <div id="wb_text13" style="position:absolute;left:95px;top:197px;width:330px;height:29px;z-index:29" align="center" <font style="font-size:20px" color="#FF0000" face="Arial"><u>Incorrect Username or password!</u></font></div> my doctype is... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  11. login.php <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if(isset($_POST['Login'])){ // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "profile.php" session_register("myusername"); session_register("mypassword"); header("location:profile.php"); } else { header(""); } } ?> profile.php <?php session_start(); if(!$_SESSION['myusername']){ header("location:index.php"); } ?> <html> <body> Login Successful </body> </html> login form <form name="form1" method="post" action="login.php"> <input type="text" id="myusername" style="position:absolute;left:651px;top:59px;width:174px;font-family:Arial;font-size:13px;z-index:4" size="29" name="myusername" value="" title="username"> <input type="password" id="mypassword" style="position:absolute;left:651px;top:86px;width:174px;font-family:Arial;font-size:13px;z-index:5" size="29" name="mypassword" value="" tabindex="password" title="password"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="on" style="position:absolute;left:648px;top:113px;font-family:Arial;font-size:13px;z-index:6"> <input type="submit" id="Button1" name="Login" value="Login" style="position:absolute;left:778px;top:117px;width:50px;height:43px;font-family:Arial;font-size:13px;z-index:8" title="Login"> </form>
  12. i do not understand cookies one little bit, even after those guides all i want is to remember the username from mysql, i do not want to remember the password
  13. Do i put this code on the page where you login or the profile page when logged in?? void session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure= false [, bool $httponly= false ]]]] )
  14. this is my form to login <form name="form1" method="post" action="checklogin.php"> <input type="text" id="myusername" style="position:absolute;left:651px;top:59px;width:174px;font-family:Arial;font-size:13px;z-index:4" size="29" name="myusername" value="" title="username"> <input type="password" id="mypassword" style="position:absolute;left:651px;top:86px;width:174px;font-family:Arial;font-size:13px;z-index:5" size="29" name="mypassword" value="" tabindex="password" title="password"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="on" style="position:absolute;left:648px;top:113px;font-family:Arial;font-size:13px;z-index:6"> <input type="submit" id="Button1" name="Login" value="Login" style="position:absolute;left:778px;top:117px;width:50px;height:43px;font-family:Arial;font-size:13px;z-index:8" title="Login"> </form> but i don't actually know how to get the "remember me" to work or where to put the script.
  15. if i type into my url "www.squiblo.com/profile.php" it come us with a page and "Login Successfull" but i havent even logged in. The same page comes up when logging in properly which i would expect the script for the profile page is show below. i would like the page to redirect to a different page if not logged in but i do not know where to start. <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } ?> <html> <body> Login Successful </body> </html>
  16. i change my else to: else { header("location: http://www.google.com"); } } ?> i used google just to test and it works, so i will just create a new page with another login form
  17. it directs me to a blank page, view for yourself go to www.squiblo.com. the page is protected because its not finished, the password to view the site is "allsaints".
  18. when an incorrect username or password is entered it directs me to a DIFFERENT page showing "Incorrect username or password", but what i want is "Incorrect username or password" to show on the same page next to the "login" button
  19. will i have to change my script completly?
  20. hi, im quite a noob to php and i need some help with login, what i want is, an error message to appear on the same page as the login page saying something like "Wrong username or password" when someone has made a mistake logging in. "session_register("myusername"); session_register("mypassword"); header("location:profile.php"); } else { echo "Wrong Username or Password"; }" this script i have directs me to another page while i want the error message to appear on the same page, does anyone have a solution?
×
×
  • 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.