Jump to content

Recommended Posts

Hi Everyone,

 

I'm in the process of creating a new form that stores customer input into a MySQL database.  What i'm attempting to do is allow them to fill out their data, and hit 'next' to go on to a file upload form.  Upon completing that form and submitting, all information (including their data from page 1) is posted at the same time (so it's all under the same ID).  What would be the easiest way to do this?  Right now my submit file (submitquote.php) contains the following data (all on one page).

 

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','date');
pt_register('POST','company');
pt_register('POST','name');
pt_register('POST','address');
pt_register('POST','city');
pt_register('POST','state');
pt_register('POST','zipcode');
pt_register('POST','phonenumber');
pt_register('POST','extension');
pt_register('POST','fax');
pt_register('POST','email');
pt_register('POST','website');
pt_register('POST','instructions');
$instructions=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $instructions);pt_register('POST','quantity');
$file01=$HTTP_POST_FILES['file01'];
$file02=$HTTP_POST_FILES['file02'];
$file03=$HTTP_POST_FILES['file03'];
if($name=="" || $email=="" || $instructions=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($HTTP_POST_FILES['file01']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file01']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file01']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['file02']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file02']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file02']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['file03']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file03']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file03']['name'].", was not uploaded!";
$errors=1;
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['file01']['name'];
$image_list[14] = $image_part;
copy($HTTP_POST_FILES['file01']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['file02']['name'];
$image_list[15] = $image_part;
copy($HTTP_POST_FILES['file02']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['file03']['name'];
$image_list[16] = $image_part;
copy($HTTP_POST_FILES['file03']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="date: ".$date."
company: ".$company."
name: ".$name."
address: ".$address."
city: ".$city."
state: ".$state."
zipcode: ".$zipcode."
phonenumber: ".$phonenumber."
extension: ".$extension."
fax: ".$fax."
email: ".$email."
website: ".$website."
instructions: ".$instructions."
quantity: ".$quantity."
file01: ".$where_form_is."files/".$image_list[14]."
file02: ".$where_form_is."files/".$image_list[15]."
file03: ".$where_form_is."files/".$image_list[16]."
";
$message = stripslashes($message);
mail("kyleldi@mywebsite","Quote",$message,"From: $email");
$link = mysql_connect("server","user","pw");
mysql_select_db("db",$link);
$query="insert into input (date,company,name,address,city,state,zipcode,phonenumber,extension,fax,email,website,instructions,quantity,file01,file02,file03) values ('".$date."','".$company."','".$name."','".$address."','".$city."','".$state."','".$zipcode."','".$phonenumber."','".$extension."','".$fax."','".$email."','".$website."','".$instructions."','".$quantity."','".$where_form_is."files/".$image_list[14]."','".$where_form_is."files/".$image_list[15]."','".$where_form_is."files/".$image_list[16]."')";
mysql_query($query);

header("Refresh: 0;url=success.php");
?><?php 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/69932-passing-form-data-through-a-page/
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.