FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » My contact form is not emailed to me
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: My contact form is not emailed to me [message #173509 is a reply to message #173508] Sat, 16 April 2011 14:36 Go to previous messageGo to previous message
nathanir is currently offline  nathanir
Messages: 3
Registered: April 2011
Karma:
Junior Member
On Apr 16, 7:04 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 4/16/2011 3:36 AM, nathanir wrote:
>
>
>
>> I have a contact form on my contact page.I can fill in the form and
>> when I click the submit button, I am redirected to the success page
>> but I dont receive an email. I did a test with a simple php mail test
>> form and that works! I have been at it for some time trying to find
>> the error. Please help
>>   The relevant code is: (for the contact form)
>> <form action="process-form.php" method="post" enctype="application/x-
>> www-form-urlencoded" target="_blank" id="formMail">
>>        <span id="textNameField">
>>        <label for="name"></label>
>>        <input type="text" name="name" id="name" />
>>        <span class="textfieldRequiredMsg">A value is required..</
>> span><span class="textfieldMinCharsMsg">Minimum number of characters
>> not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum
>> number of characters.</span></span><span id="textEmailField"><br />
>>        <br />
>> <label for="email"></label>
>>        <input type="text" name="email" id="email" />
>>        <span class="textfieldRequiredMsg">A value is required..</
>> span               ><span class="textfieldInvalidFormatMsg">Invalid format.</
>> span><span class="textfieldMinCharsMsg">Minimum number of characters
>> not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum
>> number of characters.</span></span>
>>        </p>
>>        <p>&nbsp;</p>
>>        <p><span id="SelectionText">
>>        <label for="select">Purpose</label>
>>        <select name="select" id="select">
>>            <option value="Appointment" selected="selected">Appointment</
>> option>
>>            <option value="Comment">Comment</option>
>>            <option value="Question">Question</option>
>>          </select>
>>        <span class="selectRequiredMsg">Please select an item.</span></
>> span></p>
>>            <p><span id="textinput">
>>            <textarea name="textinput" id="textinput" cols="45"
>> rows="5"></textarea>
>>            <span id="countsprytextarea1">&nbsp;</span><span
>> class="textareaRequiredMsg">A value is required.</span><span
>> class="textareaMinCharsMsg">Minimum number of characters not met.</
>> span><span class="textareaMaxCharsMsg">Exceeded maximum number of
>> characters.</span></span></p>
>>            <p>
>>              <input type="submit" name="submit" id="submit"
>> value="Submit" />
>>              <input type="reset" name="reset" id="reset" value="Reset" /
>
>>            </p>
>>        <p>&nbsp;</p>
>>      </form>
>> the processing php form has this code
>
>> <?php
>> // Pick up the form data and assign it to variables
>> $name = check_input($_POST['name']);
>> $email = check_input($_POST['email']);
>> $select = $_POST['select'];
>> $textinput = check_input($_POST['textinput']);
>
>> // Build the email (replace the address in the $to section with your
>> own)
>> $ToEmail = 'raj...@childsurgeon.com';
>> $Emailsubject = "New message: $select";
>> $MESSAGE_BODY = "$name said: $textinput";
>> $mailheader = "From: $email";
>
>> // Send the mail using PHPs mail() function
>> mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader);
>
>> // Redirect
>> header("Location: success.html");
>
>> function check_input($data)
>> {
>>      $data = trim($data);
>>      $data = stripslashes($data);
>>      $data = htmlspecialchars($data);
>>      return $data;
>> }
>> ?>
>
> Your code is very unsafe and can make your site a spam relay.  Email
> forms are nothing to play with; if you don't know what you're doing, you
> are much better getting something like phpmailer, which has at least has
> some protection built into it.
>
> And why are you using stripslashes() and htmlspecialchars()?
>
> As for why it's failing - there are lots of possibilities.  What does
> mail() return?  Do you have an MTA on your machine (if Linux) or another
> machine (if Windows)?  Does the MTA require a login before sending?
>
> Did you check the data you're using?  i.e. echo the $ToEmail, etc., to
> ensure they have what you expect?  What does your PHP error log show?
>
> There are lots of possibilities here.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Thanks Jerry for your reply. Well I am a newbie setting up my first
website in Dreamweaver. Everywhere I turned, I was instructed on how
essential it was to have one contact form. Further research revealed
http://myphpform.com/final-form.php Since I already had my form on my
contact page, I picked up the necessary php script and tested it out.
I obviously goofed and am in deeper water than what I intended to
tread. However if you will point me to the right path, I am more than
willing to learn.
BTW when I tested this script on my webpage it did send out an email
to me. This one also came from the same site.
<?php
mail('rajesh(at)childsurgeon(dot)com','Test mail','The mail function is
working!');
echo 'Mail sent!';
?>
Rajesh Nathani
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: doctype not found?
Next Topic: Re: Weird stuff
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 01:35:59 GMT 2024

Total time taken to generate the page: 0.03838 seconds