Ultrashock Forums > Flash > Data Communication
Help with PHP login system with blob (id picture)

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Help with PHP login system with blob (id picture)
Old 2008-06-25

First off, im a newbie to PHP so please go easy on me.

I wanted to create a simple login system that can upload a photo of a user that when he login he'll be redirected to his account and their individual id picture will appear. I already have a login system but i dont know how to integrate the tutorial i've read from the net.

here's the scenario:

index.php --> ask for a username and password, if success redirected to account.php

account.php --> show the id pic of the user.

user_registration.php --> username, password and upload id picture.

currently, i already have a working login system but i don't know how to view the id picture.

Pls see code below:

how do i view the id of the user here uniquely for each user? I always get an error on this and i have to manually set the id to eg. "1" or "2" before i can view it.

PHP Code:
<?php
//account.php
$username "";
$password "";
$host "localhost";
$database "";

@
mysql_connect($host$username$password) or die("Can not connect to database: ".mysql_error());

@
mysql_select_db($database) or die("Can not select the database: ".mysql_error());

$id $_GET['id'];

if(!isset(
$id) || empty($id)){
die(
"Please select your image!");
}else{

$query mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row mysql_fetch_array($query);
$content $row['image'];

header('Content-type: image/jpg');
echo 
$content;

}

?>
and how do i add a username and password + confirm password on this code

PHP Code:

//registration.php
<?php

// Create MySQL login values and 
// set them to your login information.
$username "";
$password "";
$host "localhost";
$database "";

// Make the connect to MySQL or die
// and display an error.
$link mysql_connect($host$username$password);
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}

// Select your database
mysql_select_db ($database); 

// Make sure the user actually 
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

      
// Temporary file name stored on the server
      
$tmpName  $_FILES['image']['tmp_name'];  
       
      
// Read the file 
      
$fp      fopen($tmpName'r');
      
$data fread($fpfilesize($tmpName));
      
$data addslashes($data);
      
fclose($fp);
      

      
// Create the query and insert
      // into our database.
      
$query "INSERT INTO tbl_images ";
      
$query .= "(image) VALUES ('$data')";
      
$results mysql_query($query$link);
      
      
// Print results
      
print "Thank you, your file has been uploaded.";
      
}
else {
   print 
"No image selected/uploaded";
}

// Close our MySQL Link
mysql_close($link);
?>
btw, i already have a database for this.

I really need help with as i already spent weeks just to figure out and i can't find a tutorials on google as same as this.

Any help would greatly appreciated. Thanks.
+++++++++++++++++++++++++++++++++++++++++++++++++
Pisotens is back. :)
postbit arrow 2 comments | 1590 views postbit arrow Reply: with Quote   
Registered User
pisotens is offline
seperator
Posts: 1,109
2003-07-31
Age: 29
pisotens lives in Philippines
seperator

Ultrashock Member Comments:
pisotens pisotens is offline pisotens lives in Philippines 2008-06-26 #2 Old  
Just a thought:

Since, i dont know how to make a user profile creation if i'll add an upload image and instead manually upload the image to the db. How do i display the image and i identify the correct id picture of the user?
Reply With Quote  
pisotens pisotens is offline pisotens lives in Philippines 2008-06-26 #3 Old  
or how about i manually put it on a folder and accessed by php then view and match by its username. If this is possible, any idea or sample code?
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: