Jump to content

JeBu

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JeBu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. For example, when some link is clicked and it should now include somefile.php, but when the file is not found, I should echo "Error"; not those warnings, without changing PHP settings Second problem----------- Not PHP (css) How to do so, that I have page, i.e "index.php" and a stylesheet named "style.css". I have input fields in "index.php" which gets his style from "style.css". But there is a link also in my index and when I click on that link, it includes a page, where are also input fields, but I want to add different style to them. At the moment it is taking style from style.css to my included page also.
  2. Thanks, ignace, your post was very heplful, but I don't understand that sesswhat is session_set_save_handler() all about , as much as I know at the moment it us used to store session variables in db, but not further. Could anyone give me an article about session_set_save_handler() function. (those functions doesn't make sense to me at the moment)
  3. Yes I know that, but how to write it down properly, that I don't have to refresh my browser to see the results
  4. How should it look like?
  5. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Simple login system</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="main"> <div id="header"> <form action="" method="POST"> <label for="kasutaja">User:</label> <input type="text" name="kasutaja" id="kasutaja" /> <label for="parool">Pass:</label> <input type="password" name="parool" id="parool" /> <button type="submit" name="login">Login</button> <?php if ( isset($_SESSION['logged_user']) ) { echo "<button type=\"submit\" name=\"logout\">LogOut</button>"; echo "Logged in: <b>".$_SESSION['logged_user']."</b>"; } else { echo "Welcome, guest"; } ?> </form> <?php if ( isset($_POST['login']) ) { if( (!empty($_POST['kasutaja'])) && (!empty($_POST['parool'])) ) { $db_addr = "localhost"; $db_user = "root"; $db_pass = ""; $db_name = "membership"; $user = $_POST['kasutaja']; $pass = $_POST['parool']; $con = mysql_connect($db_addr, $db_user, $db_pass) or die( mysql_error() ); mysql_select_db($db_name) or die( mysql_error() ); $query = "SELECT userNames,passWords FROM accounts"; $selected = mysql_query($query) or die( mysql_error() ); while( $account = mysql_fetch_array($selected) ) { if (($user==$account['userNames']) && ($pass==$account['passWords'])) { $_SESSION['logged_user'] = $user; break; } } } } ?> </div> </div> </body> </html> Okay, I've got a robust login system here, but there are some problems. For example, when I enter correct username and password and hit "Login", it registers a $_SESSION variable named 'logged_user'. But the username will be visible after I hit the login button and refresh a page, I'd like to do a "normal" login system that I click "login" and it logs in - it means I have to rebuild a system, but how? --it's my first login system so it may seem quite weird. --Second problem is - how to build a LogOut button? Thanks
  6. Yes I know, but how are the variables set/how they can be accessed (only by $_GET[]?) and I would like to know more, articles are welcomed
  7. How it is done? I mean...hm.. for example, i have following HTML code <a href="index.php?option=login">Log in</a> ..and a PHP code to switch pages <?php switch($_GET['option']) { case "login": { include("login.php"); break; default: { echo "Error 404"; break; } } ?> Do I just type a variable in the URL and switch it with php or what?..pff.. Any kind of help/link/article is welcome And articles about PHP headers are also welcome
  8. Try putting <?php session_start(); ?> at the very top of your pages. Both pages must have it!
  9. Yes, I know that (using 'NULL's for example for id's).
  10. How is it safe to send info to MySQL database? Should I encrypt/encode the data before sending it? for example: <?php ... //connection is established ... $insert = "INSERT INTO table_name VALUES('$var1', '$var2')"; mysql_query($insert); ?> Is it possible to use get access to my database, i.e to DROP TABLE/DATABASE or smth. Have heard of MySQL injection Any help/link is welcome
  11. Well, I have easyphp installed on my computer and now, when I've got the php basics and quite fluent in html & css, I would like to get into MySQL to build some simple login systems and so on.. Would you suggest me some tutorial or book of MySQL? Jebu..
×
×
  • 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.