graphics in form

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

graphics in form

Post by rami »

feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


may be this question has been discussed amny time but i didnt found good answer so i am posting it.

i have a page that enters data to database

Code: Select all

<?php # Script 6.10 - register.php

// Set the page title and include the HTML header.
$page_title = 'Register';
include ('templates/header.inc');

if (isset($_POST['submit'])) { // Handle the form.

	// Register the user in the database.
	require_once ('../mysql_connect.php'); // Connect to the db.
		
	// Create a function for escaping the data.
	function escape_data ($data) {
		global $dbc; // Need the connection.
		if (ini_get('magic_quotes_gpc')) {
			$data = stripslashes($data);
		}
		return mysql_real_escape_string($data, $dbc);
	} // End of function.

	$message = NULL; // Create an empty new variable.
	
	// Check for a first name.
	if (empty($_POST['first_name'])) {
		$fn = FALSE;
		$message .= '<p>You forgot to enter your first name!</p>';
	} else {
		$fn = escape_data($_POST['first_name']);
	}
	
	// Check for a last name.
	if (empty($_POST['last_name'])) {
		$ln = FALSE;
		$message .= '<p>You forgot to enter your last name!</p>';
	} else {
		$ln = escape_data($_POST['last_name']);
	}
	
	// Check for an email address.
	if (empty($_POST['email'])) {
		$e = FALSE;
		$message .= '<p>You forgot to enter your email address!</p>';
	} else {
		$e = escape_data($_POST['email']);
	}

	// Check for a username.
	if (empty($_POST['username'])) {
		$u = FALSE;
		$message .= '<p>You forgot to enter your username!</p>';
	} else {
		$u = escape_data($_POST['username']);
	}
	
	// Check for a password and match against the confirmed password.
	if (empty($_POST['password1'])) {
		$p = FALSE;
		$message .= '<p>You forgot to enter your password!</p>';
	} else {
		if ($_POST['password1'] == $_POST['password2']) {
			$p = escape_data($_POST['password1']);
		} else {
			$p = FALSE;
			$message .= '<p>Your password did not match the confirmed password!</p>';
		}
	}
	
	if ($fn && $ln && $e && $u && $p) { // If everything's OK.

		$query = "SELECT user_id FROM users WHERE username='$u'";		
		$result = @mysql_query ($query); // Run the query.
		if (mysql_num_rows($result) == 0) {
			// Make the query.
			$query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";		
			$result = @mysql_query ($query); // Run the query.
			if ($result) { // If it ran OK.
			
							echo '<p><b>You have been registered!</b></p>';
	.
				exit(); // Quit the script.
				
			} else { // If it did not run OK.
				$message = '<p>You could not be registered due to a system error. We apologize for any inconvenience.</p>
a copied but understood code

what i want to do is i want to add a colunm in the table which can store grahic
i think its blod
how it is done
create table tablename(
...
variablename blob;
....
);
or how

and how is it inserted from that php page


"$query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";

what changes are required...


next any adjustment should be made any where in os or server or any where...


and how it can be viewed

will
select grahicvariable from table ....
will work
any examples

may be some body can write small understoodable code


really thanks
rami
(core question:i want to enter ,upload photo to database from form and then display it)


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

viewtopic.php?t=36110

to find others, search:
keywords (image OR picture OR thumbnail) AND (database OR MySQL)
Search for any terms or use query as entered selected
click submit.
Post Reply