Problems with form 2 email

Discussion in 'Web Design & Coding' started by ziptrx, Jul 5, 2008.

  1. ziptrx

    ziptrx OSNN Addict

    Messages:
    53
    My problems are probably quite simple and I'm just overlooking them. I've created a form with a submit button that is only to be enabled once you agree to the terms, but it si refusing to work properly for me. The button is enabled once the page loads and disables when you check the box, which is completely backwards. The second problem is the submit button is not processing like it should. Instead of the form being emailed and a new page loading, nothing happens. The problems can be seen here. http://immixdesigns.net/test/job_form/form.php

    Thanks for any help.
     
  2. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    disable the button by default. (enabled="false" in the html)

    THen just flip the button state when the check box is clicked.
     
    ziptrx likes this.
  3. ziptrx

    ziptrx OSNN Addict

    Messages:
    53
    Thanks for the reply. I did what you suggested with the needed results. Now my problem is the button isn't working. I click on it and nothing happens. Here is the beginning code for my form
    Code:
    <form action="process_form.php" method="post" enctype="text/plain" name="applicationForm"  >
    and for my button
    Code:
    <input type="button" name="submitButton" value="Submit" disabled="true" >
    From my understanding, clicking on the button should move to the process_form.php, which has all the email commands, and post all fields to their assigned variables and an email should be sent in a readable format due to this command: enctype/text. Am I understanding this correctly?
     
  4. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    change type to submit :)
     
  5. ziptrx

    ziptrx OSNN Addict

    Messages:
    53
    As I expected, simple errors that I just overlooked. Thank you for your help. Now time for me to see if I can handle the rest of it. Thanks again.

    [ADD]
    Now I've run across a problem on the email side. I can get the email to be sent, but it lists the Send To email twice, the subject line is incomplete and all fields are not included; only nonvariable characters are seen.

    Here is the PHP code.
    Code:
    <?php
    /* recipients */
    $to1  = 'emailaddress@email.com';
     
    /* email subject line */
    $subject1 = "Application for Employment for $name1";
     
    /* message */
    $name1 = $_POST ['name'];
    $ssn1 = $_POST ['ssn'];
    $dob1 = $_POST ['dob'];
    $email1= $_POST ['email'];
     
    $message1 = "NAME:". $name1 ."\r\n";
    $message1 .= "SSN:". $ssn1 ."\r\n";
    $message1 .= "Date of Birth:". $dob1 ."\r\n";
    $message1 .= "Email Address:". $email1 ."\r\n";
     
    /* additional headers */
    $headers1 .= "To: ". $to1 ."\r\n";
    $headers1 .= "From: ". $email1 ."\r\n";
    $headers1 .= "Reply-To: ". $email1 ."\r\n";
     
    mail($to1, $subject1, $message1, $headers1)
     
    ?>
    
    Now this is my understanding, which isn't much since I'm new to PHP, and I'm following a variety of sites to build this:
    $to1 is the sendto email address, but do not understand why it lists the address twice on the email. It displays as To: email; email.

    $subject1 is the email subject, which should display as application for employment from $name1, but it does not display the $name1 variable.

    $headers1 is self explanatory, but does not display at all in the email.

    $message1 is the the body of the email, which only displays and executes everything in quotations, but no info is passed from the variables.
     
    Last edited: Jul 5, 2008
  6. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    I have this on a form I developed for work:

    Code:
    if (mail($recipient,$subject,$mail_body,"From: " . $details['E-mail'] . "\r\nReply-To: " . $details['Email'] . "\r\n"))
    
    I also notice you're putting the recipient in the headers as well :)
     
  7. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
  8. ziptrx

    ziptrx OSNN Addict

    Messages:
    53
    I read about the input sanitization and noticed that is applies to PHP 5.2. This server is running PHP 4.3.11, so adding the sanitization only brings errors. If I understand correctly, the sanitization is used to "clean" the input data so it is readable or meets a set format in the email. I receive emails fine but it seems that the variables are not being set with the info entered into the form. Thanks for your constant help, LordOfLA.
     
  9. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    sanitisation also removes in code injection from the variable too.

    The server must not be running PHP4 it was EOL in January and its security support stops 8th of August at the latest. Any scripts not supporting PHP5 should be scrapped.
     
  10. ziptrx

    ziptrx OSNN Addict

    Messages:
    53
    Found out the problem was caused by this: enctype="text/plain". Thanks again for taking the time to help.