Jump to content

Kev0121

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kev0121's Achievements

Member

Member (2/5)

0

Reputation

  1. Well in my database in my users table i have a field called 'active' and when users are logged in it changes to 1. What im trying to do is write a sql statement that says check if the user id of $_SESSION['uid'] if their active field is set to 1, if so echo out "Online" if that makes sense? sorry lol didnt know how to describe. something like this... $sql = "SELECT active FROM users WHERE active = 1 AND id = ' " . $_SESSION['uid'] . " ' "; Thanks /Kev
  2. Hello, well ive created a database class which has simple mysql functions like, query, numrows, fetch_array and ive created a new class in a seperate file called users and i created a new instance of the database class $db = new Database(); but when i use it in my user class it doesnt work, for example require_once 'database.php'; class User { var $user; var $pass; function select_a() { $sql = "SELECT * FROM users"; $res = $db->query($sql); } } Helllp please =D /Kev
  3. lol thanks i typed in tests instead of test! thanks alot Kevin
  4. Heres my error and heres my code <?php $q = "SELECT * FROM `tests`"; $qinfo = mysql_query($q); while($post = mysql_fetch_array($qinfo)) { echo "<div id=\"postinfo\">"; echo $post['title']; echo "<a hrer=\"edit.php?id=$_GET[id]\">Edit </a>"; echo "</div"; } ?> Thanks Kevin
  5. Hey, i actually realised the problem was i was on the wrong database on phpmyadmin rofl, but those posts helped thanks alot Kevin
  6. Isnt inserting anything into my database heres my code <?php include 'connection.php'; ?> <html> <head> <title>Insert Into Blog</title> </head> <body> <form action = "<?php $_SERVER['PHP_SELF']; ?>" method="POST" name="insert"> <table> <tr> <td>Post Title : <input type="text" name="pTitle" /> </td> <tr> <tr> <td>Post Author : <input type="text" name="pAuth" /> </td> <tr> <td>Post Content : <br/> <input type="text" name="pContent"/> </td> <tr> <td><input type="submit" name="Submit" value="Done" /> </td> </table> </form> </body> </html> <?php $title = $_POST['pTitle']; $author = $_POST['pAuth']; $content = $_POST['pContent']; if(isset($_POST['Submit'])) { $insertData = "INSERT INTO `test` (title,author,content) VALUES ('$title', '$author', '$content')"; $query = mysql_query($insertData) or die(mysql_error()); } ?>
  7. heres the error when i add mysql_error()) onto end of query code i get this error and heres my code <?php include 'connection.php'; $query = "SELECT * FROM `test` WHERE ID = $_GET[id]"; $result = mysql_query($query); $post = mysql_fetch_array($result); ?> Kevin
  8. Thanks alot works Kevin
  9. Getting error message when inserting information into my database heres my errror Heres my code <?php include 'connection.php'; ?> <html> <head> <title>Insert Into Blog</title> </head> <body> <form action = "<?php $_SERVER['PHP_SELF']; ?>" method="POST" name="insert"> <table> <tr> <td>Post Title : <input type="text" name="pTitle" /> </td> <tr> <tr> <td>Post Author : <input type="text" name="pAuth" /> </td> <tr> <td>Post Content : <br/> <input type="text" name="pContent"/> </td> <tr> <td><input type="submit" name="Submit" value="Done" /> </td> </table> </form> </body> </html> <?php $title = $_POST['pTitle']; $author = $_POST['pAuth']; $content = $_POST['pContent']; if(isset($_POST['Submit'])) { $insertData = "INSERT INTO `test` (title,author,content) VALUES ($title, $author, $content)"; $query = mysql_query($insertData) or die(mysql_error()); }else { echo "Error"; } ?>
  10. Well, basically trying to create just a simple register script but getting errors.. 1) Its been inserted into the database but its shown as blank and cant see the name or password 2) I get these errors.. Notice: Undefined index: username in C:\wamp\www\PHPDesk\testreg.php on line 31 Notice: Undefined index: password in C:\wamp\www\PHPDesk\testreg.php on line 32 Notice: Undefined variable: user in C:\wamp\www\PHPDesk\testreg.php on line 34 Notice: Undefined variable: user in C:\wamp\www\PHPDesk\testreg.php on line 36 Successfully Registered The Username '..'. Heres my code <?php include "functions.php"; $c = mysql_connect('localhost', 'root', '') or die("Error Connecting To Host." . mysql_error()); $db = mysql_select_db('website') or die("Error Selecting Database." . mysql_error()); if(!isset($_POST['submit'])) { ?> <link rel="stylesheet" type="text/css" href="style.css" /> <form action="" method="post" name="login"> <fieldset id="login"> <legend>Register</legend> Username<br /> <input type="text" name="uname" id="name" maxlength="15" size="20" /><br /> Password<br /> <input type="password" name="pass" id="password" /> <br /> <input type="submit" name="submit" value="Register" /> </fieldset> <?php } else { { $users = protect($_POST['username']); $pass = protect($_POST['password']); $sql = "INSERT INTO `users` (username, password) VALUES ('$user', '$pass')"; $res = mysql_query($sql); echo "Successfully Registered The Username '.$user.'."; } } ?>
  11. Thanks alot it worked How would i turn it off btw ?
  12. Well basically heres my error Notice: Undefined index: submit in C:\wamp\www\Website\register.php_phpd_tmp14.php on line 5 and heres my code i have no idea whats wrong with it <?php include "functions.php"; connect(); if(!$_POST['submit']) { echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n"; echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n"; } else { $user = protect($_POST['username']); $pass = protect($_POST['password']); $confirm = protect($_POST['passconf']); } ?>
  13. Does it does work on my server, it works when i use phpDes and im entering the location of it, its called index.php also im using VS.PHP 2.5
  14. Well basically it displays the code in the browser insted of like doing what its ment to do if that makes sense? Im using wamp and VS and php editor <?php $host = 'localhost'; $user = 'root'; $pass = ''; $db = 'website'; $c = @mysql_connect('$host', '$user', '$pass') or die("Error Connecting To Host." . mysql_error()); @mysql_select_db('$db') or die("Error Connecting To Database." . mysql_error()); if(isset($_POST['username'])) { if(!$_POST['username'] || !$_POST['password']) { die (' Please make sure you fill out all of the required fields. '); } $user = mysql_real_escape_string($_POST['username']); $user = stripslashes($user); $pass = mysql_real_escape_string($_POST['password']); $pass = sha1($pass); if(strlen($user) < 4) { die (ucwords(' Please make sure that the username is 4 or more characters. ')); } if(strlen($pass) < 4) { die (ucwords(' Please make sure that the password is 4 or more characters. ')); } $check = "SELECT * FROM `users` WHERE `username` = '$user'"; $sql = mysql_query($check); $row = mysql_num_rows($sql); if($row >= 4) { die (' Sorry but the username '.$user.' is already in use. '); } $ins = "INSERT INTO `users` (username, password) VALUES ('$user', '$pass')"; $q = mysql_query($ins); } ?>
×
×
  • 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.