SarahSaunders24 Posted February 23, 2010 Share Posted February 23, 2010 Hi Everyone, I have a brochure request form that when a user fills it out, it should write the data to a text file (until we get a proper database up), send me a confirmation email just alerting me the form has been filled out, not with all the info, and then send the data to a third party who will be fulfilling the brochure requests. I am trying to do this all in one swoop. Below is the actual form: <form action="brochure-request-process.php" method="post"> <div class="form-left"> <label class="form-label-b" for="f_name">First Name*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="f_name" type="text" class="form-input-b" maxlength="20" /><br /> <label class="form-label-b" for="l_name">Last Name*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="l_name" type="text" class="form-input-b" maxlength="25" /><br /> <label class="form-label-b" for="company">Company</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="company" type="text" class="form-input-b" maxlength="33" /><br /> <label class="form-label-b" for="j_title">Job Title</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="j_title" type="text" class="form-input-b" maxlength="33" /><br /> <label class="form-label-b" for="phone">Phone</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="phone" type="text" class="form-input-b" maxlength="12" /><br /> <label class="form-label-b" for="email">Email*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="email" type="text" class="form-input-b" maxlength="60" /><br /> <label class="form-label-qty-b" for="qty1">Number of brochures requested</label> <select name="qty1" class="qty" size="1"> <option value="one" selected="selected">1</option> <option value="two">2</option> <option value="three">3</option> <option value="four">4</option> <option value="five">5</option> </select><br /> </div> <div class="form-right"> <label class="form-label-b" for="addr1">Address 1*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="addr1" type="text" class="form-input-b" maxlength="40" /><br /> <label class="form-label-b" for="addr2">Address 2</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="addr2" type="text" class="form-input-b" maxlength="40" /><br /> <label class="form-label-b" for="city">City*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="city" type="text" class="form-input-b" maxlength="25" /><br /> <label class="form-label-b" for="st_prov">State/Province</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="st_prov" type="text" class="form-input-b" maxlength="23" /><br /> <label class="form-label-b" for="p_cd_zip">Postal Code</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="p_cd_zip" type="text" class="form-input-b" maxlength="10" /><br /> <label class="form-label-b" for="country">Country*</label><img src="images/input-left.gif" width="6" height="20" alt="" class="formInputLeft-b" /><input name="country" type="text" class="form-input-b" maxlength="23" /><br /> <input type="image" name="btnSubmit" value="Submit" src="images/input-btn-submit.png" width="94" height="36" border="0" align="right" style="margin-right:15px;"> </div> </form> and here is the brochure-request-process.php file that the above form is posting to: <?php /* Check all form inputs using check_input function */ $f_name = check_input($_POST['f_name'], "Enter your first name"); $l_name = check_input($_POST['l_name'], "Enter your last name"); $company = check_input($_POST['company']); $j_title = check_input($_POST['j_title']); $phone = check_input($_POST['phone']); $email = check_input($_POST['email'], "Enter an Email Address"); $addr1 = check_input($_POST['addr1'], "Enter an Address"); $addr2 = check_input($_POST['addr2']); $city = check_input($_POST['city'], "Enter City"); $st_prov = check_input($_POST['st_prov']); $p_cd_zip = check_input($_POST['p_cd_zip'], "Enter a Postal Code"); $country = check_input($_POST['country']); $fp = fopen("brochurerequest/data.txt", 'a'); flock($fp, LOCK_EX); $ds = ""; $ds .= $_POST['f_name']."|"; $ds .= $_POST['l_name']."|"; $ds .= $_POST['company']."|"; $ds .= $_POST['j_title']."|"; $ds .= $_POST['phone']."|"; $ds .= $_POST['email']."|"; $ds .= $_POST['addr1']."|"; $ds .= $_POST['addr2']."|"; $ds .= $_POST['city']."|"; $ds .= $_POST['st_prov']."|"; $ds .= $_POST['p_cd_zip']."|"; $ds .= $_POST['country']."|"; $ds .= "\r\n"; fwrite($fp, $ds); flock($fp, LOCK_UN); fclose($fp); mail("[email protected]", "Brochure request", "A brochure request has been submitted."); $url = 'http://www.leadnet.com/tlms/record-stmaarten.cgi?source=WEB&issue=020210' .'&f_name=' . urlencode($_POST['f_name']) .'&l_name=' . urlencode($_POST['l_name']) .'&company=' . urlencode($_POST['company']) .'&j_title=' . urlencode($_POST['j_title']) .'&phone=' . urlencode($_POST['phone']) .'&email=' . urlencode($_POST['email']) .'&addr1=' . urlencode($_POST['addr1']) .'&addr2=' . urlencode($_POST['addr2']) .'&city=' . urlencode($_POST['city']) .'&st_prov=' . urlencode($_POST['st_prov']) .'&p_cd_zip=' . urlencode($_POST['p_cd_zip']) .'&country=' . urlencode($_POST['country']) .'&qty1=' . urlencode($_POST['qty1']) .'&ad_ident1=KIT%2d01' .'&debug=1'; $page = ''; $fh = fopen($url,'r'); if (!$fh) { echo "<p>$php_errormsg</p>\n"; } else { while (! feof($fh)) { $page .= fread($fh,1048576); } } fclose($fh); /* Redirect visitor to the thank you page */ header('Location: brochure-request-thanks.php'); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <head> <title>St. Maarten Tourist Bureau</title> <?php include ("includes/scripts.php");?> <link rel="stylesheet" type="text/css" href="css/turquoise.css" id="colorchange" /> </head> <body style="background-color:#272727;"> <div class="outer-container-brochure"> <div class="outer-content" style="background-color:#06a39a;"> <div class="tab-form current"> <img src="images/main-img-brochure-request.jpg" width="750" height="250" style="position:absolute;top:0px;left:0px;" alt="" /> <div class="scroll-holder-brochure-form" style="width:750px;"> <div class="content"> <div id="contact_form"> <h1 style="padding-top:20px;">Error</h1><p>Please correct the following error in the form:<br /><br /> <span style="color:#025b54; font-size:15px;"><strong><?php echo $myError; ?></strong></span><br /><br /> <a href="javascript:history.back()">Click here</a> to return to form.</p> </div> </div> </div> </div> </div> <div class="nav-maagical"> <p style="padding:20px;"></p> </div> </div> </body> </html> <?php exit(); } ?> Everything works except where I need it to send to the third party brochure fulfillment folks. Am I passing the form data to them correctly here? Or is there another way to do it? Any help would be greatly appreciated. Im a relative newbie. Link to comment https://forums.phpfreaks.com/topic/193116-sumbit-form-data-to-2-places/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.