Search the Community
Showing results for tags 'users'.
-
Here's what I am trying to do. Users Table user_id, sponsor_id, username, filled_positions, position_1, position_2, position_3, position_4, position_5 1 0 user 1 4 user 2 user 3 user 4 user 5 2 1 user 2 2 user 4 user 5 3 1 user 3 4 2 user 4 5 2 user 5 Above is a "Users" table. Here's what I am trying to do. Insert new users into the table. Say I already have the users table set up with 5 users. I want to add User 6. I want to loop through the users in the table and find the next empty position and update it with the new user id. In this scenario diagram above, the next empty position is Row 1 - position_5. The one after that is Row 2 - position_3 and then Row 2 - position_4...etc. It basically loops through rows and checks each position. So User 6 will be placed under Row 1 - position_5 and User 7 will be placed under Row 2 - position_3. How can one go on about doing that?
-
Hi We had an online aptitude test written for us back in 2004/2005. A user registers on our site then can take a test that evaluates what type of learner they are. After they complete the test, we can send them a .pdf report. The front end of our site is a wordpress site, the testing center is written in php. Once a user registers, they get a link on our site that sends them out of wordpress to the PHP testing pages. Question: if we have 4-5 users sign up at once ( which isn't a problem in wordpress ), is there a way to allow for those users to take the aptitude test all at once. As of now, the "testing center" part of our site is only allowing 1 user at a time. Is this how PHP works? Is it the hosting server? We are hosted by Network Solutions. The test is around 120 questions long and 3 pages. Thanks in advance.
-
Hello I hope that someone can help me i am trying to do the following: i am trying to do the following i have a login name and password and the redirects me depending on the level the works correctly. Table Users id_user user pass city Type //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Table City id_city id_student city //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Table Student id_student id_city name last name grade number card city -------------- login.php--------------------------------------------------------------------------------------------- <form id="form1" name="form1" method="post" action="cargar_login.php"> <table width="800" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td colspan="2">blablabla</td> </tr> <tr> <td width="370">User</td> <td width="389"><input type="text" name="user" id="user" /></td> </tr> <tr> <td>Password</td> <td><input type="text" name="pass" id="pass" /></td> </tr> <tr> <td><input type="submit" name="boton" id="boton" value="Send" /></td> </tr> </table> </form> --------------finish login.php (form)------------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// example name of the teacher name: Peter Pass .12345 or wteu12, wherever... City: Chicago Type :Teacher --------------Star cargar_login.php------------------------------------------------------------------------------- <?php include"conexion/conexion.php"; $consulta = "SELECT * FROM Users WHERE user = '{$_POST['user']}' AND pass = '{$_POST['pass']}'"; $datos = mysql_query($consulta, $id); $numDatos = @mysql_num_rows($datos); if ($numDatos <= 0) { echo"</p> <p> </p> <p> </p>"; echo"<link href='../stylesheets/tabla.css' rel='stylesheet' type='text/css' />"; echo "<center><table width='800' border='0' cellpadding='5' cellspacing='5'>"; echo"<tr>"; echo"<td class='textoerror'>"; echo "<img src='error.png' width='46' height='46'/>\n Error: User or Pass are Incorrect.\n<a href='login.php'>Tray Again</a>"; echo""; echo"</td>"; echo"</tr>"; echo"</table></center>"; } if(isset($_POST["boton"])) { $user = $_POST['user']; $pass = $_POST['pass']; $user = stripslashes($user); $pass = stripslashes($pass); $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $sql = "SELECT * FROM Users WHERE (user= '$user') AND pass='$pass'"; $resultados = mysql_query($sql); $count = mysql_num_rows($resultados);//counting table rows $derechos=mysql_fetch_array($resultados); //fetch contents from db @session_start(); $_SESSION['usuario'] = $user; if($derechos['type'] == "Supadmin"){ header("Location: supadmin/index.php"); // if userlevel admin } //if($derechos['type'] == "Admin"){ //print "<meta http-equiv=Refresh content=\"2 ; url=admin/index.php\">"; // if userlevel admin//} elseif($derechos['type'] == "Admin"){ header("Location: admin/index.php"); // if userlevel admin } elseif($derechos['type'] == "Teacher"){ header("Location: teacher/index.php"); // if userlevel teacher } elseif($derechos['type'] == "Students"){ header("Location: students/index.php"); // if userlevel students } elseif($derechos['type'] == "Parents"){ header("Location: parents/index.php"); // if userlevel parents } } else { echo "The user or Password is not Correct!"; } ?> --------------finish cargar_login.php------------------------------------------------------------------------------------ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Example he logs seccions teacher : Peter and called a teacher/index.php and already registered to be able to see all the students of teacher Peter, who lives in Chicago and he want to see all the students of Chicago in the main section of teacher (teacher/index.php). I think that to bring the data of teacher Peter what i have to do with the union of two tables i suppose that this is the Users and City and the union is for :id_city --------------this are secciob of teacher/index.php------------------------------------------------------------------------------------ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// <?php session_start(); if(!isset($_SESSION['user'])) { header('Location: ../login.php'); exit(); } $usuario = $_POST['user']; $clave = $_POST['pass']; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// And here is where you should get a list of all the students of the teacher Peter who is from Chicago In the code sample below(teacher/index.php) already concerned in many ways but i can't ... Help as i do so is what I do not understand please help I know that the code is bad, but this is my idea try to do this code...or call /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------------Satr teacher/index.php------------------------------------------------------------------------------------ $id = mysql_connect("localhost", "root", ""); mysql_select_db("nueva", $id); $consulta_mysql="select User.*, city.* FROM user, city WHERE (user= '$user') AND pass='$pass"; $res=mysql_query($consulta_mysql,$id); if (!$res) { die('Error in the table: ' . mysql_error()); } while($registro=mysql_fetch_array($res)) { echo"<td>"; echo $registro["user"] ; echo"</td>"; echo"<td>"; echo $registro["city"] ; echo"</td>"; } ?>
-
Find number of regular users and how long they tend to be users
Staggan posted a topic in MySQL Help
Hello I am trying to work out how many regular users I have to my site and how long those users tend to be users.. So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id. I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that... SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; So ideally a number of users in each month that visited over x times, users who visited at least x times for 3 months, 6 months, 9 months, 12 months.. Any suggestions would be appreciated Thanks -
All my code is returning is the username... Please help. index.php <?php include('user.class'); $user = new user("Jbonnett", "0", "Admin", "Jamie", "Bonnett", "jbonnett@site.co.uk", "01/09/1992"); echo "username: " . $user->getUsername() . "<br/>"; echo "id: " . $user->getId() . "<br/>"; echo "level: " . $user->getLevel() . "<br/>"; echo "Forename: " . $user->getForename() . "<br/>"; echo "Surname: " . $user->getSurname() . "<br/>"; echo "Email: " . $user->getEmail() . "<br/>"; echo "Dob: " . $user->getDob() . "<br/>"; ?> user.class <?php class user { private $username; private $id; private $level; private $forename; private $surname; private $email; private $dob; public function user($username, $id, $level, $forname, $surname, $email, $dob) { $this->setUsername($username); $this->setId($id); $this->setLevel($level); $this->setForename($forename); $this->setSurname($surname); $this->setEmail($email); $this->setDob($dob); } public function destroy() { unset($this->username); unset($this->id); unset($this->level); unset($this->forename); unset($this->surname); unset($this->uemail); unset($this->dob); } public function setUsername($username) { $this->username = $username; } public function getUsername() { return $this->username; } public function setId($id) { $this->id = $id; } public function getId() { return $this->$id; } public function setLevel($level) { $this->level = $level; } public function getLevel() { return $this->level; } public function setForename($forename) { $this->foreName = $forename; } public function getForename() { return $this->forename; } public function setSurname($surname) { $this->surName = $surname; } public function getSurname() { return $this->surname; } public function setEmail($email) { $this->email = $email; } public function getEmail() { return $this->email; } public function setDob($dob) { $this->dob = $dob; } public function getDob() { return $this->dob; } }; ?>
-
Hi Guys, I'm wondering if anyone knows how to design a users display page or can lead me to a tutorial on how to design a users display page that outputs the users in thumbnail form... So like for instance..... SELECT * FROM users WHERE state = Victoria; and then showing all the users that are from the State of Victoria in, say, 108px by 108px thumbnails .... eight thumbnails wide, with their username showing up in a separate label when you hover over the thumbnails .... I'll clarify it further if need be, but I've managed to mock it up in HTML and Javascript, I've just forgotten how to get it done using PHP. (I have the users my database already, just waiting there) Any help would be much appreciated! Cheers
-
I have an old website with users and password (not hashed) and want to import them into mysql, then run a script to create a new user_password_hash and update the database: what I tried is something like this: require 'application/config/config.php'; #Define Connection String Using PDO. $dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8',DB_USER,DB_PASS); $sth = $dbh->prepare("SELECT user_id, password, user_password_hash FROM users"); $sth->execute(); $result = $sth->fetchAll(); foreach($result as $key => $value) { $query = "UPDATE users SET user_password_hash = password_hash('result.password', PASSWORD_DEFAULT) WHERE user_id = 'result.user_id'"; } echo 'Done'; but not working tried it a few different ways but unsuccessfully frustrating, new to php, used cfm in the past, trying to get my php feet wet !!! any suggestions are appreciated !!!
-
Hi. Sorry if I've posted in the wrong forum or something - I joined this forum a few seconds ago. I'm trying to create something which displays all of the users in a database table in a drop-down menu. I've tried this code: <?php include 'config.php'; session_start(); $suser = $_SESSION['user']; $con = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); mysql_select_db($config['database']); $cpuTable = $config['cpuTable']; $query = mysql_query("SELECT * FROM $cpuTable WHERE suser='$suser'"); while($row = mysql_fetch_assoc($qa)) { $users = $row['username']; echo " <select name='cpuser'> <option value='user'>$users</option> </select>"; } I created two users in the database - "cp_test1" and "cp_test2", tried the code and it outputted this: Instead of listing the users in one drop-down menu, it creates two and lists one in each. Can anyone help? Thanks
-
I followed this YouTube tutorial on how to make a registration page with a username and password. Also a login page that checks you credentials against the database and logs you in. After you are logged in, it starts a session. That's where it stopped. I want to do two things. I want to display on the site if you are logged in or if you are visiting as a guest. And my site's main purpose is photo uploading. So I would like to have under each uploaded photo the username of who uploaded it, or guest if they were not registered. I really am clueless on where to go from here. So if anyone could even point me in the right direction that would be great. I am teaching myself to program and am totally new to sessions, users etc. Here is the config.php file <?php $sql = mysql_connect("localhost","root","") or die(mysql_error()); $slect_db = mysql_select_db("login", $sql); ?> The registrer.php file <?php include ('config.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); if (empty($username)) { echo("You have to fill in an username!"); } else { if(empty($password)){ echo ("You have to fill in a password!"); } else { $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $rows = mysql_num_rows($query); } if ($rows > 0) { die("Username taken!"); } else { $user_input = mysql_query("INSERT INTO users (username, password) VALUES ('$username','$password')"); echo("Succesfuly Registered!"); } } } ?> <html> <head> <title>Register</title> </head> <body> <form action="register.php" method="post"> Username: <input type="text" name="username" /><br/> Password: <input type="password" name="password"/><br/> <input type="submit" value="Register!"/> </form> </body> </html> and the login.php file <?php include ("config.php"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $query_rows = mysql_num_rows($query); if($query_rows > 0) { echo ("Succesfull Login!"); session_start(); $_SESSION['login'] = "1"; } else { echo ("Username and/or password incorrect"); } } ?> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="post"> Username: <input type="text" name="username" /><br/> Password: <input type="password" name="password"/><br/> <input type="submit" value="Login!"/> </form> </body> </html>
-
So I have this code that checks if a user if banned on the website or not (Through a MySQL database) However, this code that DID IN FACT work, is not working anymore. Whenever I try to check if a player is banned, that I know for sure are banned, they show up as not banned. I have no clue what happened to change the way it works, but all I know is that is doesn't work anymore. Here is what I have: config.inc.php: <?php session_start(); error_reporting(1); mysql_connect("localhost", "root", "<hidden>")or die("DB connection failed: " . mysql_error()); mysql_select_db("bridge")or die("DB selection failed"); ?> index.php: <?php require_once("config.inc.php"); error_reporting(0); $action = $_GET["a"]; if ($action=="checkban"){ $player = $_GET["p"]; $username = mysql_real_escape_string($_GET["p"]); $result = mysql_query("SELECT * FROM player_bans WHERE UPPER(player_bans) = UPPER('$username') LIMIT 1"); $row = mysql_fetch_array($result); if ($row["banned"] == 1){ echo("success"); //send(array($row)); } else { echo("failiure<br />"); echo($row["banned"]); } } ?> Here is the player_bans table as well:
- 5 replies
-
- php
- phpmyadmin
-
(and 1 more)
Tagged with:
-
Hi everyone. I'm having a bit of trouble with my registration script. When I go to my action.php file, I get these error: Notice: Undefined index: uname1 in C:\xampp\htdocs\series\action.php on line 2 Notice: Undefined index: pword1 in C:\xampp\htdocs\series\action.php on line 3 But, When I test my script, Everything works fine. I don't understand what's going on. These are my two files: index.php: <html> <body> <form action="action.php" method="post"> Username: <input type="text" name="uname1" /> Password: <input type="password" name="pword1" /> <input type="submit" value="Login" /> </form> </body> </html> action.php: <?php $username_1 = $_POST['uname1']; $password_1 = $_POST['pword1']; $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect: '. mysql_error()); } mysql_select_db("user1", $con); mysql_query("INSERT INTO userlogin (username, password) VALUES ('$username_1', '$password_1')"); mysql_close($con); ?>
-
As long as it's SQL injection proof, would it be alright for me to let non-members add comments to a post and give the Author the ability to delete them?