Thread: PHP Form POST

    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Originally Posted by ManiacDan
    1) So it is, I assumed his copy/paste of code was...your code. I don't know what he was even saying anymore, so disregard that whole conversation

    4) Just use this:
    PHP Code:
    $str '<table border=1 cellpadding=3>';
    foreach ( 
    $_POST as $k => $v ) {
      
    $str .= "<tr><td><b>{$k}</b></td><td>{$v}</td></tr>";
    }
    $str .= '</table>'
    Then, $str will be a table containing everything in $_POST. Echo it, and also email it (getting HTML content to show up in an email is a whole other exercise though).
    Thank you so much :-)

    It is working :-)

    Quick question though... I have added $str to my mail function, but it is not including in the email.. is that what you were referring to regarding sending html in an email?

    PHP Code:
    $str '<table border=1 cellpadding=3>'
                   foreach ( 
    $_POST as $k => $v ) { 
                   
    $str .= "<tr><td><b>{$k}</b></td><td>{$v}</td></tr>"
                   } 
                   
    $str .= '</table>';  
                   if(
    mail($to$subject$message$headers$str)){  
           echo 
    "Message sent successfully...<br />"
           echo 
    $message;
           echo 
    $str;
           }else{
           echo 
    'Error! try again';
        }

  2. #17
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    $str should be part of the message, not just tacked on to the end of the function call (which would make it the additional email headers)
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0

    Red face


    Originally Posted by ManiacDan
    $str should be part of the message, not just tacked on to the end of the function call (which would make it the additional email headers)
    Thank you. I have removed $str from the mail section, and the new code is now part of the $message, but it is still not including in the email being sent?

    PHP Code:
    $message "<table><tr><td>Enquiry Date</td><td>".$_POST['dateToday']."</td></tr>
                   <tr><td>Conference Name</td><td>"
    .$_POST['conferenceName']."</td></tr>
                   <tr><td>Company Name</td><td>"
    .$_POST['companyName']."</td></tr>
                   <tr><td>First Name</td><td>"
    .$_POST['firstName']."</td></tr>
                   <tr><td>Last Name</td><td>"
    .$_POST['lastName']."</td></tr>
                   <tr><td>Tel No</td><td>"
    .$_POST['telNo']."</td></tr>
                   <tr><td>Cell No</td><td>"
    .$_POST['cellNo']."</td></tr>
                   <tr><td>E-Mail</td><td>"
    .$_POST['email']."</td></tr>
                   <tr><td>Special Requests</td><td>"
    .$_POST['comment']."</td></tr>
                   </tr></table>"
    ;
                   
    $str '<table border=1 cellpadding=3>'
                   foreach ( 
    $_POST as $k => $v ) { 
                   
    $str .= "<tr><td><b>{$k}</b></td><td>{$v}</td></tr>"
                   } 
                   
    $str .= '</table>'
                   if(
    mail($to$subject$message$headers)){  
           echo 
    "Message sent successfully...<br />"
           echo 
    $message;
           echo 
    $str;
           }else{
           echo 
    'Error! try again';
        }

  6. #19
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    $str is not part of message. Use $str instead of message. Delete everything with $message and replace it with $str.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #20
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Originally Posted by ManiacDan
    $str is not part of message. Use $str instead of message. Delete everything with $message and replace it with $str.
    please excuse my ignorance

    It is working fine now

    Thank you very much. I appreciate your assistance and your patience
  10. #21
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Is it perhaps possible for the form field "labels" to be displayed in the table and not the field names?

    ie, instead of "dateToday", could it display "Enquiry Date" ?
  12. #22
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    Not easily with what you have.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,797
    Rep Power
    529
    Don't really know what you are asking, but maybe something like the following will help:
    PHP Code:
    $whatIAmGiven="dateToday";
    $translate=array("dateToday"=>"Enquiry Date""somethingElse"=>"Something Else");
    $whatIWant=$translate[$whatIAmGiven]; 
  16. #24
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Originally Posted by NotionCommotion
    Don't really know what you are asking, but maybe something like the following will help:
    PHP Code:
    $whatIAmGiven="dateToday";
    $translate=array("dateToday"=>"Enquiry Date""somethingElse"=>"Something Else");
    $whatIWant=$translate[$whatIAmGiven]; 

    Thank you for your reply. Where would I insert this?
    Before or after the mail function?
  18. #25
  19. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,864
    Rep Power
    368
    Originally Posted by ultramel123
    Thank you I have tried to do this but it's returning this error

    Parse error: syntax error, unexpected <' in /home/airportg/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()d code on line 29

    ( i copied it exactly as you suggested, perhaps I inserted the code in the incorrect place?)
    it was not intended as a complete code.. you were supposed to do one or the other.. and think what the other is doing and why you would be getting an error..
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,864
    Rep Power
    368
    Originally Posted by ultramel123
    Is it perhaps possible for the form field "labels" to be displayed in the table and not the field names?

    ie, instead of "dateToday", could it display "Enquiry Date" ?
    you could:

    1. name the form element on page1 as enquire_date
    2 on second page, get rid of _ and upper case them.. (in the loop)

    (do not COPY this code straight)

    page 1
    <input name="enquire_date" value="" />

    page 2
    foreach ($_POST as $name=>$value){
    $name = // strip _ and upper case
    echo $name.
    }
  22. #27
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Thank you Paul. I have adjusted page 1 as specified.

    Now I have tried to do this by adding the following:

    PHP Code:
    $str =      '<table border=1 cellpadding=3 width="500">'
                   foreach ( 
    $_POST as $k => $v ) { 
                   
    $str .= "<tr><td><b>{$k}</b></td><td>{$v}</td></tr>";
                   
    $str .= ucwords($str);
                   } 
                   
    $str .= '</table>'
    I am now receiving this error:

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 77176893 bytes) in /home/airportg/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 20 ?
  24. #28
  25. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,864
    Rep Power
    368
    look at that again.. what you are doing.. you didnt follow me exactly.

    you are not doing anything with $k ?
  26. #29
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    Thank you,

    Ok I see now what you are referring to (I think).

    $k refers to the "field name" (not sure on term)
    $v refers to the value which is POSTED?

    I have changed it to this:

    PHP Code:
    $str =      '<table border=1 cellpadding=3 width="500">'
                   foreach ( 
    $_POST as $k => $v ) { 
                   
    $str .= "<tr><td><b>{$k}</b></td><td>{$v}</td></tr>";
                   
    $k .= ucwords($k);
                   } 
                   
    $str .= '</table>'
  28. #30
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    27
    Rep Power
    0
    I have also tried:

    PHP Code:
    $k .= ucfirst($k); 

IMN logo majestic logo threadwatch logo seochat tools logo