form for taking an order and uploading a file. - php Form

Author Topic: form for taking an order and uploading a file.  (Read 3848 times)

Offline phon

  • Supporter
  • **
  • Posts: 4
  • Karma: +0/-0
    • View Profile
form for taking an order and uploading a file.
« on: September 14, 2008, 08:26:14 AM »


hi, I have done some basic PHP tutorials and have coded Flash AS2 a few years ago. I now have to make an order form and file upload for a friend - I'm looking for ideas to get me going.

1) I need to begin my making a form that can accept data such as name, email, and so on.
2) then add the ability to upload a file with the form.
3) then work out where this information is sent to (email, ..?...
4) then play with the file upload part as I think the file has to be sent to a different server than the one the site is hosted on.

any ideas to help me? do i need to explain more?

i am just a little stuck as how to start as I have not made anything in PHP before :)

Offline phon

  • Supporter
  • **
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #1 on: September 15, 2008, 08:48:29 PM »
i now have a script for file uploading, i have edited it to my needs. I am now looking to add to the form to give more fields i require.

i'm not sure if this is an inactive forum or i am in the wrong place for help... :)

if anyone is here, please point me to some simple form examples please, I am obviously trying already from my end but so far not hitting the resources i need. any tips appreciated.

Offline alex

  • Global Moderator
  • *****
  • Posts: 77
  • Karma: +19/-0
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #2 on: September 15, 2008, 10:55:01 PM »
http://phpform.net/board/index.php/topic,12.0.html
 :)

Offline phon

  • Supporter
  • **
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #3 on: September 15, 2008, 11:19:24 PM »
thanks :)

that is a mail form, i'm slowly getting to grips with bits of all this and i'm not sure that is what i need.

My aim it to have a form that a user fills and an upload file box.

the aim is that they can give a few details about themeslves and upload a file.

what i can't grasp is where the info goes once sent and how i deal with it once it has been sent. I do have an upload system working and an info box taking a name. I can't work out where the name is going on send or how to deal with the name and other details i pick up via the form.

Offline alex

  • Global Moderator
  • *****
  • Posts: 77
  • Karma: +19/-0
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #4 on: September 16, 2008, 11:17:05 AM »
Pear Package: HTTP_Upload
http://pear.php.net/package/HTTP_Upload
Download:
http://pear.php.net/package/HTTP_Upload/download
 :) :)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +10/-0
  • Gender: Male
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #5 on: September 16, 2008, 03:45:18 PM »
FILES

1. Folder "uploads"

2. blank sett.php file

3. install.php:
Code: [Select]

<form name="formcheck" action="install1.php" method="POST">
<table width="100%" text align="center" border="0">
<tr>
  <td align="center" width="120">Host</td>
  <td align="center"><input type=text style="font-size: 18px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #000000 1px solid ; BACKGROUND-COLOR: #F8F8F8" input name="host"  size="30"></td>
</tr>
<tr>
  <td align="center" width="120">DB Name</td>
  <td align="center"><input type=text style="font-size: 18px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #000000 1px solid ; BACKGROUND-COLOR: #F8F8F8" input name="name" size="30"></td>
</tr>
<tr>
  <td align="center" width="120">DB Password</td>
  <td align="center"><input type=text style="font-size: 18px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #000000 1px solid ; BACKGROUND-COLOR: #F8F8F8" input name="pass" size="30"></td>
</tr>
<tr>
  <td align="center" width="120">DB Username</td>
  <td align="center"><input type=text style="font-size: 18px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #000000 1px solid ; BACKGROUND-COLOR: #F8F8F8" input name="user" size="30"></td>
</tr>

<tr>
  <td>
  </td>
  <td align="center">
 <br><br><center>

<INPUT TYPE="SUBMIT" name="submit" VALUE=" Submit"
STYLE="font-family:verdana;
font-size:12px; font-weight:bold; font-style:none; border-style:solid;
 border-color:#0C0D0C; border-width:1px; background:#CCCCCC; color:#CC0000; width:8em">
<INPUT TYPE="RESET" name="reset" VALUE=" Reset"
STYLE="font-family:verdana;
font-size:12px; font-weight:bold; font-style:none; border-style:solid;
 border-color:#0C0D0C; border-width:1px; background:#CCCCCC; color:#CC0000; width:8em">

</center>
</font>
</form>


4.install1.php

Code: [Select]

<?php
$host 
$_POST['host'];
$name $_POST['name'];
$pass $_POST['pass'];
$user $_POST['user'];
$hosts '$dbhost';
$users '$dbusername';
$password '$dbpassword';
$names '$dbname';
$link '$link';
$dbhost '$dbhost';
$urlh '$urlh';
$db '$db';
$dbname '$dbname';
$dbusername '$dbusername';
$dbpassword '$dbpassword';
$myFile "sett.php";
$fh fopen($myFile'w') or die("can't open file- check CHMOD");
$stringData 
"<?php 
$hosts = '$host';
$users = '$user';
$password = '$pass';
$names = '$name';
$link=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$link) :
   die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $link);
if(!$db) :
   die ('Can\'t connect to database : ' . mysql_error());
endif;
?>
";
fwrite($fh, $stringData);
fclose($fh);

?>
<center><h3>
<a href = "install2.php">STEP 2</a>
</h3></center></font>


5. install2.php

Code: [Select]
<?php
include ('sett.php');

mysql_query("CREATE TABLE `commenty` (
  `commid` int(5) NOT NULL auto_increment,
  `text` text collate utf8_unicode_ci,
  `uploadedfile` text collate utf8_unicode_ci,
  `date` datetime NOT NULL,
  `text1` text collate utf8_unicode_ci,
  PRIMARY KEY  (`commid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"
)
or die(
mysql_error());
?>


6. index.php

Code: [Select]
<center><strong><font face="verdana">Form</strong><br>

<br>
<br>
<form enctype="multipart/form-data" action="submit.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />

<input name="text" />

<input name="text1" />
<input type="submit" value="submit" />
</form>

7. submit.php

Code: [Select]

<?php

///// Code from Tizag.com FILE Upload "uploader.php"

$target_path "uploads/";

$target_path $target_path basename$_FILES['uploadedfile']['name']); 

if(
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo 
"The file ".  basename$_FILES['uploadedfile']['name']). 
    
" has been uploaded";

/////

include ('sett.php');
$text $_POST['text'];
$text1 $_POST['text1'];
$uploadedfile basename$_FILES['uploadedfile']['name']);

$result mysql_query("INSERT INTO commenty (text, uploadedfile, date, text1)
VALUES ('$text','$uploadedfile',NOW(),'$text1')"
)
or die(
mysql_error());


} else{
    echo 
"There was an error uploading the file, please try again!";
}

?>

<a href="index.php">Write</a>
<a href="comment.php">Read</a>


8. comment.php

Code: [Select]
<?php
include ('sett.php');
$resulty mysql_query("SELECT * FROM commenty")
or die(
mysql_error()); 
while(
$row=mysql_fetch_array($resulty)){
echo
"<center><hr>";
echo
"Name:";
echo 
$row['text'];
echo
"<br>";
echo
"Date:";
echo 
$row['date'];
echo
"<br>";
echo
"Comments:";
echo 
$row['text1'];
echo
"<br>";
$fily $row['uploadedfile'];
echo 
"<img src=uploads/$fily>";
echo 
"</center><hr>";
 }
?>

;)
« Last Edit: September 16, 2008, 03:52:08 PM by admin »

Offline phon

  • Supporter
  • **
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: form for taking an order and uploading a file.
« Reply #6 on: September 16, 2008, 06:08:35 PM »
ok, if i said i want to learn latin and you handed me 3 books in latin - lets say i'm in a similar position now :D

i have a working upload script, it sends a file to a folder called uploads.

i have the form collecting a little data like $Pname name

SO... if the file goes to uploads,where does the form data go?

can i have the form data collected and emailed off, or better still put into a form they can print?

right now I don't know how to collect and use the form data, only the upload part works... can they both operate off the same button?