PHP pass parameters from html form

Johnny

I come from C# background and im new to php, I have an html form submits it's values to the following php file and for some reason the values are not set, what am I doing wrong?

<?php
include('Mail.php');
$recipients = "[email protected]";
$name = $_POST["txtName"] ;
$from = $_POST["txtEmail"] ;
$subject = $_POST["txtAppName"] ;
$comments = $_POST["txtComment"] ;

$headers = array (
    'From' => $from,
    'To' => $recipients,
    'Subject' => $subject,
);
$body = "Name: ".$name."\r\n"."Comments: "."\r\n".$comments;
$mail_object =& Mail::factory('smtp',
    array(
        'host' => 'prwebmail',
        'auth' => true,
        'username' => 'username',
        'password' => 'pass', # As set on your project's config page
        'debug' => true, # uncomment to enable debugging
    ));
$mail_object->send($recipients, $headers, $body);
?>

And here is the html form:

<form action="sendfeedback.php" method="post">
            <div><input placeholder="Name" id="txtName" type="text" /></div>
            <div><input placeholder="Email (Optional)" id="txtEmail" type="text" /></div>
            <div><input placeholder="Application Name (Type in the application name you're using)" id="txtAppName" type="text" /></div>
            <div style="height:4px"></div>
            <div><textarea placeholder="Comments..." id="txtComment"></textarea></div>
            <div style="width:407px; text-align:right;"><input id="submitComment" type="submit" value="Send" /></div>
        </form>
António Almeida

Your form inputs should have the attribute name, like this:

<form action="sendfeedback.php" method="post">
    <div><input placeholder="Name" id="txtName" name='txtName' type="text" /></div>
    <div><input placeholder="Email (Optional)" id="txtEmail" name="txtEmail" type="text" /></div>
    <div><input placeholder="Application Name (Type in the application name you're using)" id="txtAppName" name="txtAppName" type="text" /></div>
    <div style="height:4px"></div>
    <div><textarea placeholder="Comments..." id="txtComment" name='txtComment'></textarea></div>
    <div style="width:407px; text-align:right;"><input id="submitComment" type="submit" value="Send" /></div>
</form>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Pass Data from HTML Form to MySQL Database using PHP

From Dev

Pass Data from HTML Form to MySQL Database using PHP

From Dev

How to pass parameters to a URL from a select form?

From Dev

Pass some parameters from the action to a form view

From Dev

Pass multiple parameters from a jQuery function to PHP

From Dev

pass html form elements as arguments to a php function

From Dev

Pass variable from PHP into HTML

From Dev

How to pass input variable from HTML Form

From Dev

PHP calculation from html form

From Dev

Is it possible to pass value from php back to html form without using javascript?

From Dev

How to pass a hidden value from a html form to PHP without letting the user manipulate it?

From Dev

Pass value from php form to Paypal amount

From Dev

Pass value from php form to Paypal amount

From Dev

How to pass selected rows from a table as request parameters on form submit?

From Dev

How to pass multiple parameters from Angular form to make POST request?

From Dev

PHP HTML Input Pass Multiple Parameters to jQuery AJAX Call

From Dev

PHP MySQL insert query via html form, parameters not going through

From Dev

How to pass parameters PHP with "/"

From Dev

Pass form values from PHP file to another PHP file

From Dev

How to pass parameters through iframe from parent html?

From Dev

How to pass parameters to web service URL from Phonegap HTML page

From Dev

How to pass parameters to JavaScript Function From Generated HTML

From Dev

Pass multiple variables from HTML to PHP

From Dev

Pass MYSQL data from PHP to HTML

From Dev

How to pass POST parameters from PHP to ASP Web Api?

From Dev

Pass parameters from command line to a PHP Class and Functions script

From Dev

Why can't I get HTML form to pass values to PHP?

From Dev

How can i pass parameters from datagridview to an open or main form without opening new form

From Dev

CherryPy - 400 error, Multiple values for parameters from HTML form

Related Related

  1. 1

    Pass Data from HTML Form to MySQL Database using PHP

  2. 2

    Pass Data from HTML Form to MySQL Database using PHP

  3. 3

    How to pass parameters to a URL from a select form?

  4. 4

    Pass some parameters from the action to a form view

  5. 5

    Pass multiple parameters from a jQuery function to PHP

  6. 6

    pass html form elements as arguments to a php function

  7. 7

    Pass variable from PHP into HTML

  8. 8

    How to pass input variable from HTML Form

  9. 9

    PHP calculation from html form

  10. 10

    Is it possible to pass value from php back to html form without using javascript?

  11. 11

    How to pass a hidden value from a html form to PHP without letting the user manipulate it?

  12. 12

    Pass value from php form to Paypal amount

  13. 13

    Pass value from php form to Paypal amount

  14. 14

    How to pass selected rows from a table as request parameters on form submit?

  15. 15

    How to pass multiple parameters from Angular form to make POST request?

  16. 16

    PHP HTML Input Pass Multiple Parameters to jQuery AJAX Call

  17. 17

    PHP MySQL insert query via html form, parameters not going through

  18. 18

    How to pass parameters PHP with "/"

  19. 19

    Pass form values from PHP file to another PHP file

  20. 20

    How to pass parameters through iframe from parent html?

  21. 21

    How to pass parameters to web service URL from Phonegap HTML page

  22. 22

    How to pass parameters to JavaScript Function From Generated HTML

  23. 23

    Pass multiple variables from HTML to PHP

  24. 24

    Pass MYSQL data from PHP to HTML

  25. 25

    How to pass POST parameters from PHP to ASP Web Api?

  26. 26

    Pass parameters from command line to a PHP Class and Functions script

  27. 27

    Why can't I get HTML form to pass values to PHP?

  28. 28

    How can i pass parameters from datagridview to an open or main form without opening new form

  29. 29

    CherryPy - 400 error, Multiple values for parameters from HTML form

HotTag

Archive