Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function addUser($info)
- {
- $host = "localhost";
- $user = 'root';
- $pword = '';
- $db = 'userdb';
- $mycon = mysql_connect($host,$user,$pword);
- mysql_select_db($db,$mycon);
- $name = mysql_escape_string($info['name']);
- $age = mysql_escape_string($info['age']);
- $email = mysql_escape_string($info['email']);
- $password = mysql_escape_string($info['password']);
- $description = mysql_escape_string($info['description']);
- $query = "INSERT INTO users (name,age,email,password,description)
- VALUES ('$name','$age','$email','$password','$description')";
- if(mysql_query($query))
- {
- mysql_close($mycon);
- return true;
- }
- else
- {
- mysql_close($mycon);
- return false;
- }
- }
- function getUser($email,$password)
- {
- $host = "localhost";
- $user = 'root';
- $pword = '';
- $db = 'userdb';
- $mycon = mysql_connect($host,$user,$pword);
- mysql_select_db($db,$mycon);
- $query = "SELECT * FROM users WHERE email='$email' AND password='$password'";
- $result = mysql_query($query);
- $row = mysql_fetch_array($result);
- mysql_close($mycon);
- return $row;
- }
- function getUserById($id)
- {
- $host = "localhost";
- $user = 'root';
- $pword = '';
- $db = 'userdb';
- $mycon = mysql_connect($host,$user,$pword);
- mysql_select_db($db,$mycon);
- $query = "SELECT * FROM users WHERE id='$id'";
- $result = mysql_query($query);
- $row = mysql_fetch_array($result);
- mysql_close($mycon);
- return $row;
- }
- function updateUser($data)
- {
- $host = "localhost";
- $user = 'root';
- $pword = '';
- $db = 'userdb';
- $mycon = mysql_connect($host,$user,$pword);
- mysql_select_db($db,$mycon);
- $name = mysql_escape_string($data['name']);
- $age = mysql_escape_string($data['age']);
- $email = mysql_escape_string($data['email']);
- $tagline = mysql_escape_string($data['tagline']);
- $interests = mysql_escape_string($data['interests']);
- $description = mysql_escape_string($data['description']);
- $id = $_COOKIE['uid'];
- $query = "UPDATE users SET name='$name', age='$age', email='$email', tagline='$tagline', interests='$interests', description='$description' WHERE id='$id'";
- if(mysql_query($query))
- {
- mysql_close($mycon);
- return true;
- }
- else
- {
- mysql_close($mycon);
- return false;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment