www.webdeveloper.com
Results 1 to 4 of 4

Thread: HELP *** DROP DOWN isset

  1. #1
    Join Date
    Oct 2013
    Location
    Philippines
    Posts
    3

    Exclamation HELP *** DROP DOWN isset

    Hi guys,

    will just ask help on how to set the isset for my drop down. I want it to send it to my e-mail. The Name, Email and the message is showing up correctly, bu the telephone and the dropdown has a problem.

    here's my HTML CODE:

    Code:
    <form id="form" method="post" action="send-mail.php">
                      <fieldset>
                        <label><input type="text" name="Name" value="Name" onBlur="if(this.value=='') this.value='Name'" onFocus="if(this.value =='Name' ) this.value=''"></label><br><br>
                        <label><input type="text" name="Email" value="Email" onBlur="if(this.value=='') this.value='Email'" onFocus="if(this.value =='Email' ) this.value=''"></label><br><br>
                        <label><input type="text" name="telephone" value="telephone" onBlur="if(this.value=='') this.value='telephone'" onFocus="if(this.value =='telephone' ) this.value=''"></label><br><br>
                        <label>
    	<select name="custom">
    		<option value="1m">1 month</option>
    		<option value="2m">3 months</option>
    		<option value="6m">6 months</option>
    		<option value="1y">1 year</option>
    		<option value="3y">3 years</option>
    	</select></label><br><br>
                        <label><textarea name="Message" onBlur="if(this.value==''){this.value='Message'}" onFocus="if(this.value=='Message'){this.value=''}">Message</textarea></label><br>
                        <a href="#" class="button" onClick="document.getElementById('form').submit()">Send</a></div>
                      </fieldset>                   
                    </form>
    and here's my php code:
    PHP Code:
    <?php
    if(isset($_POST['Email'])) {

        
    // CHANGE THE TWO LINES BELOW
        
    $email_to "rizzaocampo88@gmail.com";

        
    $email_subject "website html form submissions";


        function 
    died($error) {
            
    // your error code can go here
            
    echo "We're sorry, but there's errors found with the form you submitted.<br /><br />";
            echo 
    $error."<br /><br />";
            echo 
    "Please go back and fix these errors.<br /><br />";
            die();
        }

        
    // validation expected data exists
        
    if(!isset($_POST['Name']) ||
            
    //!isset($_POST['last_name']) ||
            
    !isset($_POST['Email']) ||
            !isset(
    $_POST['telephone']) ||
            !isset(
    $_POST['custom']) ||
            !isset(
    $_POST['Message'])) {
            
    died('We are sorry, but there appears to be a problem with the form you submitted.');       
        }

        
    $first_name $_POST['Name']; // required
        //$last_name = $_POST['last_name']; // required
        
    $email_from $_POST['Email']; // required
        
    $telephone $_POST['telephone']; 
        
    $telephone $_POST['custom']; 
        
    $comments $_POST['Message']; // required

        
    $error_message "";
        
    $email_exp '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!
    preg_match($email_exp,$email_from)) {
        
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
      }
        
    $string_exp "/^[A-Za-z .'-]+$/";
      if(!
    preg_match($string_exp,$first_name)) {
        
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
      }
      
    //if(!preg_match($string_exp,$last_name)) {
        //$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
      //}
      
    if(strlen($comments) < 2) {
        
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      }
      if(
    strlen($error_message) > 0) {
        
    died($error_message);
      }
        
    $email_message "Form details below.\n\n";

        function 
    clean_string($string) {
          
    $bad = array("content-type","bcc:","to:","cc:","href");
          return 
    str_replace($bad,"",$string);
        }

        
    $email_message .= "Name: ".clean_string($first_name)."\n";
        
    //$email_message .= "Last Name: ".clean_string($last_name)."\n";
        
    $email_message .= "Email: ".clean_string($email_from)."\n";
        
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
        
    $email_message .= "Custom Jewerly: ".clean_string($custom)."\n";
        
    $email_message .= "Comments: ".clean_string($comments)."\n";


    // create email headers
    $headers 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    @
    mail($email_to$email_subject$email_message$headers);  
    ?>
    <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.');
            window.location = 'contact-form.html';
        </script>

    <?php
    }
    die();
    ?>

  2. #2
    Join Date
    Feb 2012
    Posts
    102
    Well the main thing that pops out to me is that you set the variable $telephone twice here

    PHP Code:
    $telephone $_POST['telephone'];  
    $telephone $_POST['custom']; 
    I am not sure what you are trying to do with that but that seems odd to me.

  3. #3
    Join Date
    Oct 2013
    Location
    Philippines
    Posts
    3
    Hi,

    Thanks for that MCCO the phone number showed up:

    Here's the output of the form on my e-mail:

    Form details below.

    Name: test
    Email: test@test.com
    Telephone: 123456
    Custom Jewerly: 2m
    Comments: message test

    I the question is how can I get the data from the drop down?

    Thanks much for the help!

  4. #4
    Join Date
    Sep 2013
    Posts
    221
    Well, i think you must check out your " if " condition again.

    Try out withe the below example code:
    if ((!isset($action)) || ($action != "add" || $action != "delete"))

    Hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles