SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I get information from an order page to:

    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. Or is there a java script validation that will cancel out 0's in the html part of the form.
    Last edited by ghost2012; Apr 6, 2009 at 11:26.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow

    PHP Code:
    if(!(empty($_POST['formelement']))
    {
         
    //variable declaration goes here

    That'll only assign variables if they contain information. I would suggest creating an array to hold names of form elements and whether or not they're supposed to be enabled for the confirmation page, and assigning those in the empty check as well.

    Follow me?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?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 = "test@test.com";
    $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.

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    South Florida
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you receiving post data, you can check any post value by isset($_POST['your_post_var']) logic

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    When developing forms, just do this at the start of the form handling page;

    var_dump( $_POST );

    to keep an eye on what is actually happening to the variables, 0 (integer) is not the same as '0' (string) - though PHP will try and process them the same if you do not enforce strictness.

    But to answer your question, about explicitly testing for 0's, and making conditions depending upon them.

    This sample below works for both 0 and '0', by consciously not enforcing strictness with === or !== but using !=

    An example showing how to then use concatenate to add to a string to build up your message.

    PHP Code:
    $pfw_header "This is the start of the message.\n";
    $pfw_header .= "This is line two \n";

    if( 
    $phone != $pfw_header .= "Tel:  $phone\n" ;

    echo 
    $pfw_header 


    Why all those @ error suppressors?

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really sure about all the @ its from looking over other examples and putting one together that works basically. Now I'm asked to design the form where it only recieves items selected instead of the whole form itself that's where I'm lost at now. Any Ideas or suggestions I'm open for.

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The form handler only receives what it is sent.

    if nobody puts anything in this box, nothing is sent

    <input type=text id=test value="" />

    if nobody picks an item from this select, a default value is sent. If a checkbox is not checked then nothing is sent.

    You really should try all of those options in a form which posts back to itself with this line at the top.

    <?php
    var_dump($_POST);
    ?>

    Get rid of the @s then you don't need them.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •