1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problems with Hostway and a PHP script.

Discussion in 'PHP' started by virtualscouser, Dec 14, 2008.

  1. #1
    Hey I tried submitting this on the PHP Freaks forum and hit a dead end. I have a block of PHP in a form that works fine on a website I manage. Another client needed a similar form so I copied and pasted all the form along with my code and did my modifications. When I upload my page and test it, the PHP verifies the form and gives me my appropriate thank you response. However I don't receive any mail. I have verified the php.ini file and the hosting company even sent me a small PHP script that sends an email without issue. Needless to say, I'm baffled.:confused:

    Here is the script:(I have changed personal information

    <?php if (isset($_POST['submit'])) { // handle the form.

    //Check for first name.
    if (strlen($_POST['first_name']) > 0) {
    $first_name = TRUE;
    } else {
    $first_name = FALSE;
    echo '<p>You forgot to enter your first name!</p>';
    }
    //Check for last name.
    if (strlen($_POST['last_name']) > 0) {
    $last_name = TRUE;
    } else {
    $last_name = FALSE;
    echo '<p>You forgot to enter your last name!</p>';
    }
    //Check for email.
    if (strlen($_POST['email']) > 0) {
    $email = TRUE;
    } else {
    $email = FALSE;
    echo '<p>You forgot to enter your e-mail address!</p>';
    }

    if ($first_name && $last_name && $email) { //If everything's ok.
    // Good to go.

    $message .= "First Name:\t".$_REQUEST["first_name"]."\n";
    $message .= "Last Name:\t".$_REQUEST["last_name"]."\n";
    $message .= "Phone Number:\t".$_REQUEST["phone"]."\n";
    $message .= "Email:\t".$_REQUEST["email"]."\n";
    $message .= "How did you find us:\t".$_REQUEST["refered_by"]."\n";
    $message .= "Comments:\t".$_REQUEST["comments"]."\n";

    $recipient = "me@email.com";
    $subject = "Information Request";


    $mailheaders = "From: Website Request <information@website.com> \n";
    $mailheaders .= "Reply-To: information@website.com\n\n";

    mail($recipient, $subject, $message, $mailheaders);

    echo '<p>Thanks for your interest in our product. If requested, we will contact you using your provided information.</p>';
    } else { // not ok.
    echo '<p>Please go back and insert the required information.</p>';
    }

    } else { // Display the form.
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <table width="500" border="0" align="center" cellpadding="5" cellspacing="0">
    <tr>
    <td colspan="2"><div align="left"><span class="style8b">Enter your information in the form below:</span></div></td>
    </tr>
    <tr>
    <td width="150"><span class="style5"><span class="style17">*</span>First Name:</span></td>
    <td width="300"><input name="first_name" type="text" size="40" /></td>
    </tr>
    <tr>
    <td><span class="style5"><span class="style17">*</span>Last Name:</span></td>
    <td><input name="last_name" type="text" size="40" /></td>
    </tr>
    <tr>
    <td><span class="style5">Phone Number :</span></td>
    <td><input name="phone" type="text" size="40" /></td>
    </tr>
    <tr>
    <td><span class="style5">*Email:</span></td>
    <td><input name="email" type="text" size="40" /></td>
    </tr>
    <tr>
    <td><span class="style5">How did you find us?:</span></td>
    <td><input name="refered_by" type="text" size="40" /></td>
    </tr>
    <tr>
    <td><span class="style5">Comments:</span></td>
    <td><textarea name="comments" cols="40" rows="3"></textarea></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><input name="submit" type="submit" class="style5" value="Submit" /></div></td>
    </tr>
    </table>
    </form>
    <!-- End of the form -->
    <?php } ?>
     
    virtualscouser, Dec 14, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Why not posting that other script that does work so we can verify!
     
    EricBruggema, Dec 15, 2008 IP
  3. virtualscouser

    virtualscouser Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    $to = "email@mysite.com";
    $subject = "Test Message";
    $message = "Hello World!";
    $from = "anotheremail@mysite.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    ?>

    This script works without issues, the $to and the $from lines are populated with actual emails of course.
     
    virtualscouser, Dec 15, 2008 IP
  4. virtualscouser

    virtualscouser Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I take it nobody can see any problems?:(
     
    virtualscouser, Dec 17, 2008 IP