Jump to content

Recommended Posts

Here is a html form:

i need help from someone to send me the database creation code and the php code needed to add this html form in DB...

 

(ex: You put this html form in your website than Someone writes his name, surname chooses his city and uploads multiply pictures and they should be stored in DB)

 

<body>

<table border="0">

 

<form method ="post" action="">

<tr><td>Name</td><td><input type="text" name="name" size="40"></td></tr>

<tr><td>Surname</td><td><input type="text" name="surname" size=40></td></tr>

<tr><td>Email</td><td><input type="text" name="email" size="40"></td></tr>

<tr><td>Tel. Nr</td><td><input type="text" name="number" size="40"></td></tr>

<tr><td>Adress</td><td><input type="text" name="address" size="40"></td></tr>

 

<tr><td>City</td><td><select name="city" size="1">

<option selected>A

<option>B

<option>C

<option>D

<option>E

<option>F

<option>G

</select></td></tr>

 

<tr><td>Info</td><td><textarea name="comment" rows =10 cols=40>write here...</textarea></td></tr>

<tr><td>Upload </td>

 

<td align="right"><input type="hidden" name="MAX_FILE_SIZE" value="500" >

<input type="file" name="upload" size=30></td></tr>

 

<tr><td></td><td align="right">

<br/><input type="submit" name="Dergo">

</form>

</td></tr>

</table>

</body>

 

 

Thanks

People are here to help you with problems that you may have WITH CODE THAT YOU HAVE TRIED TO WRITE YOURSELF. If you want someone to write it for you from scratch then you need to post this in the freelance section and expect to pay for the work. Other wise you will more than likely be out of luck.

Ok here i want to upload a picture in database: but it doesnt work where is the problem?

 

 

 

 

here is my PHPcode:

<?php
$dbname="database_web";
$host="localhost";
$user="";
$pass="";
$link = mysql_connect($host, $user, $pass);
mysql_select_db($dbname, $link);
?>
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
  $fileName = addslashes($fileName);
}
$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed');
echo "<br>File $fileName uploaded<br>";
}
?>


and here is my SQL code:

 

CREATE TABLE upload (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
content MEDIUMBLOB NOT NULL,
PRIMARY KEY(id)
);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.