PHP Form Mistake.

Discussion in 'PHP' started by rain7, May 19, 2009.

  1. #1
    I need help.

    I use this code. But my problem is this that when I upload file to my server. and fill the form then I recive an "Empty Email".
    I dont know what mistake I am doing.

    kindly please tell me my mistake.
    I am waiting your positive response. Please help me.


    <?php
    if($_POST['submit'])
    {
    $firstName = $_POST['firstname'];
    $lastName = $_POST['lastname'];
    $companyname = $_POST['companyname'];
    $companytype = $_POST['companytype'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $location = $_POST['location'];
    $country = $_POST['country'];
    $category = $_POST['category'];

    if($othertourservice1 == 'Web Designing')
    {
    $siteurl = $_POST['siteurl'];
    $category = $_POST['category'];
    $benchmark = $_POST['benchmark'];
    $colors = $_POST['colors'];
    $screenresolutions = $_POST['screenresolutions'];
    $logodesign = $_POST['logodesign'];
    $flashintro = $_POST['flashintro'];
    $projectinformation = $_POST['projectinformation'];
    $startdate1 = $_POST['startdate1'];
    $timeframe1 = $_POST['timeframe1'];
    $estimatedbudget1 = $_POST['estimatedbudget1'];
    }

    else if($othertourservice1 == 'Web Development')
    {
    $solutions = $_POST['solutions'];
    $projectinformation2 = $_POST['projectinformation2'];
    $startdate2 = $_POST['startdate2'];
    $timeframe2 = $_POST['timeframe2'];
    $estimatedbudget2 = $_POST['estimatedbudget2'];
    }
    else if($othertourservice1 == 'Graphic Designing')
    {
    $checkbox = $_POST['checkbox'];
    $colors3 = $_POST['colors3'];
    $projectinformation3 = $_POST['projectinformation3'];
    $startdate3 = $_POST['startdate3'];
    $timeframe3 = $_POST['timeframe3'];
    $estimatedbudget3 = $_POST['estimatedbudget3'];
    $timeframe2 = $_POST['timeframe2'];
    $timeframe2 = $_POST['timeframe2'];

    }
    // Fields

    // now sending email


    $to = 'test@....com';


    // subject
    $subject = 'Quote Request Form';


    $message = '
    <html>
    <head>
    <title>Query</title>
    </head>
    <body>

    <table>
    <tr>
    <td>First Name</td>
    <td>$firstName</td>
    </tr>
    <tr>
    <td>last Name</td>
    <td>$lastName</td>
    </tr>
    <tr>
    <td>Category</td>
    <td>$category</td>
    </tr>


    </table>
    </body>
    </html>
    ';
    // message
    // message
    $message1 .= "<br>First Name: $firstname";

    $message1 .= "<br>Last Name: $lastname";

    $message1 .= "<br>Company Name: $companyname";

    $message1 .= "<br>Contact Number: $phone";

    $message1 .= "<br><br> email: $email";

    $message1 .= "<br><br> country: $country";

    $message1 .= "<br><br> category: $category";

    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'To: "test@....com'." \r\n";
    $headers .= 'From: TEST <test@....com>' . "\r\n";



    // Mail it
    mail($to, $subject, $message, $headers);
    unset($_POST);
    }
    ?>
     
    rain7, May 19, 2009 IP
  2. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Use if(isset($_POST['submit'])) instead of if($_POST['submit'])

    You have got all the values in '$message1' var, but you are sending the '$message'.
    May be this is the reason you are getting empty mail. :)
     
    srobona, May 19, 2009 IP
  3. rain7

    rain7 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh Yes now I solved my problem. My Problem Was '$message1'
    When I type message. then I solve my problem.
    Thank you veyr much sir. You are really great.


     
    rain7, May 19, 2009 IP
  4. rain7

    rain7 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sir you give me idea I did. and my form is working now. But now I have one problem.

    See this link
    infinitedesigner.com/company/webdesigning-quote.html

    This is my Html form.


    When I select othertourservice(Web designing) and I fill feilds, And then i submit the form then I recive an email all feild on my email. (Graphic Desining)(Web Developing)
    And this is not good. I just want to select one radio button and I want to recive one radion buttons feilds.
    And now this is PHP file.



    <?php
    if(isset($_POST['submit']))
    {
    $firstName = $_POST['firstname'];
    $lastName = $_POST['lastname'];
    $companyname = $_POST['companyname'];
    $companytype = $_POST['companytype'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $location = $_POST['location'];
    $country = $_POST['country'];

    if($othertourservice1 == 'Web Designing')
    {
    $siteurl = $_POST['siteurl'];
    $category = $_POST['category'];
    $colors = $_POST['colors'];
    $screenresolutions = $_POST['screenresolutions'];
    $logodesign = $_POST['logodesign'];
    $flashintro = $_POST['flashintro'];
    $projectinformation = $_POST['projectinformation'];
    $startdate1 = $_POST['startdate1'];
    $timeframe1 = $_POST['timeframe1'];
    $estimatedbudget1 = $_POST['estimatedbudget1'];
    }

    else if($othertourservice2 == 'Web Development')
    {
    $solutions = $_POST['solutions'];
    $projectinformation2 = $_POST['projectinformation2'];
    $startdate2 = $_POST['startdate2'];
    $timeframe2 = $_POST['timeframe2'];
    $estimatedbudget2 = $_POST['estimatedbudget2'];
    }
    else if($othertourservice3 == 'Graphic Designing')
    {
    $checkbox = $_POST['checkbox'];
    $colors3 = $_POST['colors3'];
    $projectinformation3 = $_POST['projectinformation3'];
    $startdate3 = $_POST['startdate3'];
    $timeframe3 = $_POST['timeframe3'];
    $estimatedbudget3 = $_POST['estimatedbudget3'];

    }
    // Fields

    // now sending email


    $to = 'test@...com>';


    // subject
    $subject = 'Quote Request Test;


    $message = '';
    // message
    // message
    $message .= "<br>First Name: $firstname";

    $message .= "<br>Last Name: $lastname";

    $message .= "<br>Company Name: $companyname";

    $message .= "<br>Company Type: $companytype";

    $message .= "<br><br> Contact Number: $phone";

    $message .= "<br><br> Email Address: $email";

    $message .= "<br><br> Current Location: $category";

    $message .= "<br><br> category: $location";

    $message .= "<br><br> Country: $country";

    $message .= "<br><br> Projects Details: $othertourservice";

    // Web Designing
    $message .= "<br><br> Site URL: $siteurl";

    $message .= "<br><br> Category: $category";

    $message .= "<br><br> 3 colors: $colors";

    $message .= "<br><br> Screen Resolutions: $screenresolutions";

    $message .= "<br><br> Logo Design: $logodesign";

    $message .= "<br><br> Flash header/intro: $flashintro";

    $message .= "<br><br> Project Information: $projectinformation";

    $message .= "<br><br> Desired Start Date: $startdate1";

    $message .= "<br><br> Desired Timeframe: $timeframe1";

    $message .= "<br><br> Estimated Budget: $estimatedbudget1";



    // Web Developing

    $message .= "<br><br> Solutions required: $solutions";

    $message .= "<br><br> Project Information: $projectinformation2";

    $message .= "<br><br> Desired Start Date: $startdate2";

    $message .= "<br><br> Desired Timeframe: $timeframe2";

    $message .= "<br><br> Estimated Budget: $estimatedbudget2";

    // Graphic Designing

    $message .= "<br><br> Graphic Designing: $checkbox";

    $message .= "<br><br> 3 colors: $colors3";

    $message .= "<br><br> Project Information: $projectinformation3";

    $message .= "<br><br> Desired Start Date: $startdate3";

    $message .= "<br><br> Desired Timeframe: $timeframe3";

    $message .= "<br><br> Estimated Budget: $estimatedbudget3";



    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'To: "test@...com>." \r\n";
    $headers .= 'From: Quote Request <test@...com>' . "\r\n";



    // Mail it
    mail($to, $subject, $message, $headers);
    unset($_POST);
    }
    ?>
     
    rain7, May 19, 2009 IP
  5. rain7

    rain7 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I know I have problem on PHP but I cant see problem. Becasue I am very weak on PHP its my first php work. So please solve my problem.
     
    rain7, May 19, 2009 IP
  6. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I can help you via PM, but I prefer instant messengers. So if you would like me to help you, please message me on one of the provided messengers on my profile
     
    NatalicWolf, May 19, 2009 IP