Jump to content

preview be for submit to db problem


nbbcj

Recommended Posts

Hi all,

 

i have been working on a form preview be for submit the info to the db iv got the preview but to work but when i add me sql insert i get page errors can any one help. Iv been racking my brain for days  now :(

 

i am using this to error report but am just getting the server error msg and no more info

ini_set('display_errors',1); 
error_reporting(E_ALL);

 

here is my form code

<form method='POST' action='add_form.php' enctype="multipart/form-data" name="form1" id="form1">
  <p>Project Name:
    <input class="addp" name="pro_name" type="text" size="40" maxlength="40" />
Category: Brand Identity:
<input name="bi" type="checkbox" value="1" checked />
Print:
<input name="print" type="checkbox" value="1" checked />
Online:
<input name="online" type="checkbox" value="1" checked />
</p>
<p>Short Details: 
  <input class="addp" name="short_details" type="text" size="100" maxlength="100"/>
</p>
<p>Full Details:
  <textarea class="tinymce" name="full_details"  cols="100" rows="1"></textarea>
</p>
<p>Thumbnail:
<input type="hidden" name="MAX_FILE_SIZE" value="1029120"/> 
  <input class="addp" name="ufile[]" type="file" id="ufile[]" size="50" />

</p>
<p> Image 1:
<input type="hidden" name="MAX_FILE_SIZE" value="1029120"/>
  <input class="addp" name="ufile[]" type="file" id="ufile[]" size="30" />

  Image 2:
   <input type="hidden" name="MAX_FILE_SIZE" value="1029120"/>
  <input class="addp" name="ufile[]" type="file" id="ufile[]" size="30" />

</p>
<p>Image 3:
<input type="hidden" name="MAX_FILE_SIZE" value="1029120"/>
  <input class="addp" name="ufile[]" type="file" id="ufile[]" size="30" />

Image 4:
<input type="hidden" name="MAX_FILE_SIZE" value="1029120"/>
<input class="addp" name="ufile[]" type="file" id="ufile[]" size="30" />

<input name="submit" type="submit" value="Submit""> 
<input name="preview" type="submit" value="Preview"">
</p>
</form>

 

here is my php

////////////this code works 
if(isset($_POST['preview'])) {
$path1= "../thumbnails/".$_FILES['ufile']['name'][0];
    $path2= "../images/".$_FILES['ufile']['name'][1];
    $path3= "../images/".$_FILES['ufile']['name'][2];
    $path4= "../images/".$_FILES['ufile']['name'][3];
$path5= "../images/".$_FILES['ufile']['name'][4];

$add_pn=$_POST['pro_name'];
$add_sd=$_POST['short_details'];
$add_fd=$_POST['full_details'];
$add_bi=$_POST['bi'];
$add_print=$_POST['print'];
$add_online=$_POST['online'];

//copy file to where you want to store file
if(!($_FILES['ufile']['tmp_name'][0] == NULL))
{ copy($_FILES['ufile']['tmp_name'][0], $path1); }

if(!($_FILES['ufile']['tmp_name'][1] == NULL))
{ copy($_FILES['ufile']['tmp_name'][1], $path2); }

if(!($_FILES['ufile']['tmp_name'][2] == NULL))
{ copy($_FILES['ufile']['tmp_name'][2], $path3); }

if(!($_FILES['ufile']['tmp_name'][3] == NULL))
{ copy($_FILES['ufile']['tmp_name'][3], $path4); }

if(!($_FILES['ufile']['tmp_name'][4] == NULL))
{ copy($_FILES['ufile']['tmp_name'][4], $path5); }



print "<pre>";
print "Preview button pressed..";
print_r($_REQUEST);
print "$add_pn  $add_sd $add_fd $add_bi $add_print $add_online";
print "</pre>";
if(!($_FILES['ufile']['tmp_name'][0] == NULL))
{ print "<img src=\"$path1\" width=\"100\" height=\"100\" align=\"textop\">"; }
if(!($_FILES['ufile']['tmp_name'][1] == NULL))
{ print "<img src=\"$path2\" width=\"100\" height=\"100\" align=\"textop\">"; }
if(!($_FILES['ufile']['tmp_name'][2] == NULL))
{ print "<img src=\"$path3\" width=\"100\" height=\"100\" align=\"textop\">"; }
if(!($_FILES['ufile']['tmp_name'][3] == NULL))
{ print "<img src=\"$path4\" width=\"100\" height=\"100\" align=\"textop\">"; }
if(!($_FILES['ufile']['tmp_name'][4] == NULL))
{ print "<img src=\"$path5\" width=\"100\" height=\"100\" align=\"textop\">"; }
}

///////////////// this bit errors
if(isset($_POST['submit'])) {
print "<pre>";
print "Submit button pressed..";
print_r($_REQUEST);
print "</pre>";

include ("../includes/db_config.php");//////////////////try'd this bit of code at the start of the page 
$con = mysql_connect($db_hostname,$db_username,$db_password);//////////////////try'd this bit of code at the start of the page
@mysql_select_db($db_database) or die( "Unable to select database");//////////////////try'd this bit of code at the start of the page

////////////////// im not sure if this is needed again ?????
$add_pn=$_POST['pro_name'];
$add_sd=$_POST['short_details'];
$add_fd=$_POST['full_details'];
$add_bi=$_POST['bi'];
$add_print=$_POST['print'];
$add_online=$_POST['online']; 
////////i have used this insert code on other pages and it works so not sure why its not now 
$sql="INSERT INTO $db_table (pro_name, thumbnail, short_details, full_details, bi, print, online, image1, image2, image3, image4)
VALUES
('$add_pn','".$_FILES['ufile']['name'][0]."','$add_sd','$add_fd','$add_bi','$add_print','$add_online','".$_FILES['ufile']['name'][1]."','".$_FILES['ufile']['name'][2]."','".$_FILES['ufile']['name'][3]."','".$_FILES['ufile']['name'][4]."')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)


}

Link to comment
Share on other sites

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.