Re: My contact form is not emailed to me [message #173511 is a reply to message #173509] |
Sat, 16 April 2011 20:11 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 4/16/2011 10:36 AM, nathanir wrote:
> 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> </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"> </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> </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.
>>
> 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
Your PHP script is not secure. Before putting a contact forum up on
your site, you really need to understand a lot about security -
otherwise you will quickly become a spam relay and your host will
probably cancel your account (at least a good one will).
And just picking a script when you don't know what you're doing is just
asking for trouble - as in your case.
If you want a good secure contact form, I would suggest you read up on
security and learn how to properly secure your site.
In the meantime, did you do the things I suggested in my previous reply?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|