dsloan Posted April 6, 2009 Share Posted April 6, 2009 How do I get information from and html order form to a Php Form developed that will take the submitted information and transfer it to the confirmation page. Only the information that was selected will be transferred. No hiding information will be allowed. Therefore the information that was selected from the order form will transfer to the confirmation page and it has been verified then the remaining information will be submitted for completion of order. I have and order form already with the php form for processing the order and responding with an email. But my problem is that the order for is very large and the client wants just what is ordered not 0's in the non ordered spaces. This is my delimea and I am a noob. So if anyone can help me please do. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/ Share on other sites More sharing options...
dsloan Posted April 6, 2009 Author Share Posted April 6, 2009 This is a demo for what am I doing. <?php // Receiving variables @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$company = addslashes($_POST['company']); @$customerCode = addslashes($_POST['customerCode']); @$address = addslashes($_POST['address']); @$phone = addslashes($_POST['phone']); @$suiteno = addslashes($_POST['suiteno']); @$orderedby = addslashes($_POST['orderedby']); @$city = addslashes($_POST['city']); @$states = addslashes($_POST['states']); @$zipcode = addslashes($_POST['zipcode']); @$item001 = addslashes($_POST['item001']); @$item002 = addslashes($_POST['item002']); @$item003 = addslashes($_POST['item003']); @$item004 = addslashes($_POST['item004']); @$item005 = addslashes($_POST['item005']); // Validation //Sending Email to form owner $pfw_header = "From: $customerCode\n" . "Reply-To: $customerCode\n"; $pfw_subject = "test subject"; $pfw_email_to = "[email protected]"; $pfw_message = "Visitor's IP: $pfw_ip\n" . "company: $company " . "customerCode: $customerCode " . "orderedby: $orderedby\n" . "address: $address " . "suiteno: $suiteno " . "phone: $phone\n" . "city: $city " . "states: $states " . "zipcode: $zipcode\n" . "item001: $item001 " . "item002: $item002 " . "item003: $item003 " . "item004: $item004 " . "item005: $item005 " @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; ?> This is a demo for the test code that I'm using. How do I get only the information that is chosing from the initial orderform which is Html to the confirmation page. That would show only what is ordered. Or is there a java script validation that will cancel out 0's in the html part of the form. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-802651 Share on other sites More sharing options...
jonsjava Posted April 6, 2009 Share Posted April 6, 2009 just FYI. the addslashes isn't enough to clean up data. Here's a simple function to get you started on easily cleaning up input: <?php /** * cleanInput: Takes either a single-dimension array or a variable, and cleans it up * making it safe for your database. * * @param array/variable $input * @return array/variable */ function cleanInput($input){ /* ************************************************************************ */ /* Either fill out the following, or include a file that established the db */ /* connection. */ /* ************************************************************************ */ $db_host = "localhost"; $db_user = "***********"; $db_pass = "***********"; $db_db = "your_db"; $link = mysql_connect($db_host, $db_user, $db_pass); mysql_select_db($db_db, $link); /* END Edit */ if (is_array($input)){ foreach ($input as $key=>$value){ $tmp = mysql_real_escape_string(html_entity_decode($value)); $output[$key] = addslashes($tmp); } } else { $tmp = mysql_real_escape_string(html_entity_decode($value)); $output = addslashes($tmp); } if ($link){ mysql_close($link); } return $output; } ?> Now, it could be made to do more, but this is an older script of mine. I use some variant of it in all my code. I'd recommend you do something similar. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-802659 Share on other sites More sharing options...
dsloan Posted April 6, 2009 Author Share Posted April 6, 2009 I see no reason to clean it up I'm not accessing any sql dbase. What I'm trying to do is extract information from an HTML form and am wanting only that which is ordered instead of the 0's that also accompany the orderform. The 0's are there due to a validation check format I'm using. So that's where I'm lost. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-802665 Share on other sites More sharing options...
Brian W Posted April 6, 2009 Share Posted April 6, 2009 something like: <?php foreach($_POST as $form => $val){ if($val == '0' || empty($val)){ unset($_POST[$form]); } } That will remove them from the $_POST array. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-802692 Share on other sites More sharing options...
dsloan Posted April 6, 2009 Author Share Posted April 6, 2009 I don't have an array built up just what is extracted after the confirmation page. If you want to see what i'm talking about this is what I'm working on. http://www.healthwisenri.com/orderform.htm this is in no way promotion for them but so you can get an understanding of what I'm working with. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-802731 Share on other sites More sharing options...
dsloan Posted April 9, 2009 Author Share Posted April 9, 2009 Brian W. you helped me with on how to get rid of the Zeros in the confirmation page. Now does anyone know how or what to write to get only that which is selected to be sent to the confirmation page. Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-805802 Share on other sites More sharing options...
jonsjava Posted April 9, 2009 Share Posted April 9, 2009 I think this will solve your problem (if I understand the issue properly): <?php // Receiving variables $items = ""; @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$company = addslashes($_POST['company']); @$customerCode = addslashes($_POST['customerCode']); @$address = addslashes($_POST['address']); @$phone = addslashes($_POST['phone']); @$suiteno = addslashes($_POST['suiteno']); @$orderedby = addslashes($_POST['orderedby']); @$city = addslashes($_POST['city']); @$states = addslashes($_POST['states']); @$zipcode = addslashes($_POST['zipcode']); foreach ($_POST as $key=>$value){ if ($value == '0' || empty($value)){ unset($_POST[$key]); } if (key_exists($key, $_POST) && strstr($key, "item")){ $value = addslashes($value); $items .= "$key: $value \n"; } } // Validation //Sending Email to form owner $pfw_header = "From: $customerCode\n" . "Reply-To: $customerCode\n"; $pfw_subject = "test subject"; $pfw_email_to = "[email protected]"; $pfw_message = "Visitor's IP: $pfw_ip\n" . "company: $company " . "customerCode: $customerCode " . "orderedby: $orderedby\n" . "address: $address " . "suiteno: $suiteno " . "phone: $phone\n" . "city: $city " . "states: $states " . "zipcode: $zipcode\n" . "$items"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; ?> Link to comment https://forums.phpfreaks.com/topic/152804-how-do-i-get-information-from-an-order-page-to/#findComment-805824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.