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 #173508 is a reply to message #173506] Sat, 16 April 2011 14:04 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
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 = 'rajesh(at)childsurgeon(dot)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.
jstucklex(at)attglobal(dot)net
==================
[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 22 16:16:03 GMT 2024

Total time taken to generate the page: 0.04187 seconds