Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Contact form issue...

    I am new to php and am building my own website. I have read a couple of books searched online and can't see what I did wrong if anything. The form is not mailing anything and when the submit button is clicked it just takes me to to a blank white page. I am checking with the host of the site to see if they have an answer for me as well. I would really appreciate it if you could take a look at my script to see if you notice what the issue might be. I really appreciate all your help and reply's.

    Here is the url to my site to see the problem in action.

    http://matthewbosick.com/contact.htm

    Html script for the form :
    PHP Code:
    <div id="content">
              </
    br>
              <
    form action="contactform.php" method="post" name="contactform" id="contactform">
                <
    table width="100%" border="0" cellpadding="0">
                  <
    tr>
                    <
    td width="5%" align="right" valign="top">*</td>
                    <
    td width="6%" align="right">Name:</td>
                    <
    td width="89%" align="left"><input name="name" type="text" id="name3" size="35" maxlength="50" /></td>
                  </
    tr>
                  <
    tr>
                    <
    td align="right" valign="top">*</td>
                    <
    td align="right">Phone:</td>
                    <
    td align="left"><input name="phone" type="text" id="phone" size="35" maxlength="12" /></td>
                  </
    tr>
                  <
    tr>
                    <
    td align="right" valign="top">*</td>
                    <
    td align="right">Email:</td>
                    <
    td align="left"><input name="email" type="text" id="email" size="35" maxlength="60" /></td>
                  </
    tr>
                  <
    tr>
                    <
    td align="right" valign="top">&nbsp;</td>
                    <
    td align="right">I am:</td>
                    <
    td align="left"><p>
                      <
    label>
                        <
    input type="radio" name="type" value="Purchasing" id="type_0" />
                        
    Purchasing</label>
                      <
    br />
                      <
    label>
                        <
    input type="radio" name="type" value="Selling" id="type_1" />
                        
    Selling</label>
                      <
    br />
                      </
    p></td>
                  </
    tr>
                  <
    tr>
                    <
    td colspan="2" align="right" valign="top">&nbsp;</td>
                    <
    td align="left"><input name="financing" type="checkbox" id="financing" value="Yes" />
                      <
    label for="financing">I need help with my loan options.</label></td>
                  </
    tr>
                  <
    tr>
                    <
    td colspan="2" align="right" valign="top">&nbsp;</td>
                    <
    td align="left"><input name="first_time" type="checkbox" id="first_time" value="Yes" />
                      <
    label for="first_time">I am a first time home buyer.</label></td>
                  </
    tr>
                  <
    tr>
                    <
    td align="right" valign="top">*</td>
                    <
    td align="right" valign="top">Message:</td>
                    <
    td align="left" valign="top"><textarea name="message" id="message" cols="30" rows="5"></textarea></td>
                  </
    tr>
                  <
    tr>
                    <
    td colspan="2" align="right" valign="top">&nbsp;</td>
                    <
    td align="left"><input name="submit" type="submit" id="submit" onclick="MM_validateForm('name3','','R','phone','','R','email','','RisEmail','message','','R');return document.MM_returnValue" value="Submit" /></td>
                  </
    tr>
                  <
    tr>
                    <
    td colspan="2" align="right" valign="top">&nbsp;</td>
                    <
    td align="left">&nbsp;</td>
                  </
    tr>
                  <
    tr>
                    <
    td colspan="2" align="right" valign="top">&nbsp;</td>
                    <
    td align="left">(*Required)</td>
                  </
    tr>
                </
    table>
              </
    form
    Php script for the form:
    PHP Code:
    <?php

        $emailSubject 
    'contactform';
        
    $webMaster 'mbosick@selectmtg.net';
        
        
    $name $_POST['name'];
        
    $phone $_POST['phone'];
        
    $email $_POST['email'];
        
    $type $_POST['type'];
        
    $financing $_POST['financing'];
        
    $first_time $_POST['first_time'];
        
    $message $_POST['message'];
        
        
    $body=<<<EOD
    <br><hr><br>
    Name: $name <br>
    Phone: $phone <br>
    Email: $email <br>
    I am: $type <br>
    Need help with financing: $financing <br>
    First home: $first_time <br>
    Message: $message
    EOD;      

        $headers = "From: $email\r\n";
        $headers .= "Content-type: text/html\r\n";
        $success = mail($webMaster, $emailSubject, $body, $headers);

        $theResults=<<<EOD
    <html>
    <head>
    <titlet>sent message</title>
    <meta http-equiv="refresh" content="4;URL=http//matthewbosick.com/index.html">
    <style type="text/css">
    <!--
    body{
        background-color: #cccccc;
        font-style: normal;
        line-height: normal;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 25 px;
        font-color: #000;
        padding-top: 300px;
    }
    -->
    </style>
    </head>
    <div align="center">Thank you for your interest, your message has been sent and will be answered as soon as possible</div>
    </body>
    </html>
    EOD;
    echo 
    "$theResults";
    ?>
    Last edited by Inigoesdr; 12-17-2010 at 02:18 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    The blank white page means you have a PHP script error,
    and your error reporting is turned off. Turn it on using your
    webhost control panel or try this at the top of your script ...

    <?php
    // Show all errors
    error_reporting(E_ALL);




    .

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    At a glance:
    The reason you are getting a blank page is probably because you have a fatal error and error reporting turned off on your server. Thus, it can't run and it also can show you the errors. If you turn error reporting on or check your php error log, you will be able to see a message telling you the problem.

    One way you can turn on error reporting is to add this to top of your PHP file:
    Code:
    error_reporting(-1);
    Try starting there and see what you get.

    EDIT: Woah! You beat me to it. :-p

  • #4
    New Coder
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thanks for that...

    I appreciate the help. I did what you suggested and got the following errors:

    20101217T113530: www.matthewbosick.com/contactform.php
    PHP Notice: Undefined variable: headers in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 31

    PHP Notice: Undefined variable: headers in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 32

    PHP Notice: Undefined variable: success in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 33

    PHP Notice: Undefined variable: body in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 33

    PHP Notice: Undefined variable

    I thought I had defined the variables. If you could give me some help to understand what is wrong with them it would be great.

    Thanks again.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I normally don't use heredocs and nowdocs ....

    Try this instead:
    PHP Code:
    <?php

        $emailSubject 
    'contactform';
        
    $webMaster 'mbosick@selectmtg.net';
        
        
    $name $_POST['name'];
        
    $phone $_POST['phone'];
        
    $email $_POST['email'];
        
    $type $_POST['type'];
        
    $financing $_POST['financing'];
        
    $first_time $_POST['first_time'];
        
    $message $_POST['message'];
        
    $body="
    <br><hr><br>
    Name: $name <br>
    Phone: $phone <br>
    Email: $email <br>
    I am: $type <br>
    Need help with financing: $financing <br>
    First home: $first_time <br>
    Message: $message
    "
    ;      

        
    $headers "From: $email\r\n";
        
    $headers .= "Content-type: text/html\r\n";
        
    $success mail($webMaster$emailSubject$body$headers);

    $theResults="
    <html>
    <head>
    <titlet>sent message</title>
    <meta http-equiv='refresh' content='4;URL=http//matthewbosick.com/index.html'>
    <style type='text/css'>
    <!--
    body{
        background-color: #cccccc;
        font-style: normal;
        line-height: normal;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 25 px;
        font-color: #000;
        padding-top: 300px;
    }
    -->
    </style>
    </head>
    <div align='center'>Thank you for your interest, your message has been sent and will be answered as soon as possible</div>
    </body>
    </html>
    "
    ;
    echo 
    "$theResults";
    ?>
    Last edited by mlseim; 12-17-2010 at 05:14 PM.

  • #6
    New Coder
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thank you so much...

    That did it! Thank you all for your help and time.


  •  

    Posting Permissions

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