Results 1 to 5 of 5

Thread: drop down email list

  1. #1
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default drop down email list

    hey everyone how can i add a dropdown box to the following script that include common email address endings? so that the person can input there username and a dropdown box with the email ex: hotmail, gmail.

    i have this form:
    Code:
    <?php
    if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
      {
      //send email
      $email = $_REQUEST['email'] ; 
      }
    else
    //if "email" is not filled out, display the form
      {
      echo "<form method='post' action='mailer2.php'>
      Email: <input name='email' type='text'/>
      <input type='submit' />
      </form>";
      }
    ?>
    
    <html>
    <center>
    David Morin -2008-
    </center>

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    PHP Code:
    <?
    $category 
    = array(
    1=> "@hotmail.com",
    2=> "@live.com",
    3=> "@gmail.com",
    4=> "@yahoo.com",
    5=> "@aol.com",
    );
    $category str_replace(" "" "$category);

    echo 
    '<SELECT name=category>';
    foreach (
    $category as $key => $value)
    {
    echo 
    '<OPTION value='.$value.'> '.$value.'';
    }
    echo 
    '</select>';

    ?>
    Although I don't recommend you do this, as there are hundreds of thousands of email addresses, and you will never cover them all.

    Another option would be to leave one as "other" and if "other" is selected allow them to type in their extension in a new text box that would appear.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey blizzard. Now how do i include that in my form? here is the link to what i have
    davidmorin.net/mailer.php

    in the field i want ppl to input there cell numbers and in the drop down a list of carriers email extentions. and then the send button ofcourse.

    Thanks for your help..

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    I had to do something similar with a form I had. I'll show you the javascript, then the form example:

    Code:
    function emailOther(theForm){
    
    	show = document.getElementById('other_input');
    
    	if (theForm.category.value=='Other...'){
    
    		show.style.display='inline';
    
    		theForm.other_input.value='';}
    
    	else{
    
    		show.style.display='none';
    
    		theForm.other_input.value='void';}
    
    }
    I'd include that in the head as a separate script.

    HTML Code:
    <script type="text/javascript" src="emailOther.js"></script>
    Now, here's how you would use it on the form:

    HTML Code:
    <select name="category" onchange="emailOther(this.form)">
    <option>@hotmail.com</option>
    <option>@live.com</option>
    <option>@gmail.com</option>
    <option>@yahoo.com</option>
    <option>@aol.com</option>
    <option>Other...</option>
    </select>
    <input type="text" name="otherEmail" id="other_input" value="void" />
    The last thing is a few lines of CSS to make sure that input is hidden:
    Code:
    #other_input{
    display: none;}
    If you have any questions, let me know.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default thanks!!

    Hey thanks alot for that.

    do you have a working script that i could see? with the email process.

    what im doing is in the backend i have a script that when the user submits email it sends them an attachment.

    thanks!

    heres the scripts im using

    mailer.php

    Code:
    <?php
    require("mailer.php");
    $to = $_REQUEST['email'];
    $from = 'test@gmail.com';
    $subject = 'Here is the subject';
    
    $boundary = 'Message-Boundary-' . date('YmdHis');
    
    $headers = 'From: ' . $from . "\n";
    $headers .= 'Reply-To: ' . $from . "\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: Multipart/Mixed; boundary=' . $boundary . "\n\n"; 
    
    $message = '--' . $boundary . "\n";
    $message .= 'Content-Transfer-Encoding: 64BIT' . "\n";
    $message .= 'Content-Type: text/html; charset=US-ASCII' . "\n\n";
    
    $message .= 'Here is your tone and pic';
    
    $attach = true;
    if($attach){
      $arrfile = array('tt88616.mp3');  
      foreach($arrfile as $f){
        $file = $f;
        $attach = fopen($file, 'rb');
        $data = fread($attach, filesize($file)); 
        fclose($attach);
        $data = chunk_split(base64_encode($data)); 
    
        $ext = strtolower(substr(strrchr($file, '.'), 1));
        switch($ext){
          case 'pdf': $type = 'application/pdf'; break;
          case 'exe': $type = 'application/octet-stream'; break; 
          case 'zip': $type = 'application/zip'; break;
          case 'doc': $type = 'application/msword'; break;
          case 'xls': $type = 'application/vnd.ms-excel'; break; 
          case 'ppt': $type = 'application/vnd.ms-powerpoint'; break;
          case 'gif': $type = 'image/gif'; break;
          case 'mp3': $type = 'audio/mpeg'; break;
          case 'mpeg': $type ='audio/mpeg'; break; 
          case 'png': $type = 'image/png'; break;
          case 'jpe':
          case 'jpeg':
          case 'jpg': $type = 'image/jpg'; break;
          default: $type = 'application/force-download'; 
        }
    
        $message .= "\n\n" . '--' . $boundary . "\n";
        $message .= 'Content-Transfer-Encoding: base64' . "\n";
        $message .= 'Content-Type: ' . $type . '; name="' . $file . '";' . "\n"; 
        $message .= 'Content-Disposition: inline; filename="' . $file . '"' . "\n\n" . $data;
      }
    }
    
    mail($to, $subject, $message, $headers);
    echo 'E-mail sent!';
    ?>
    the form.php
    Code:
    <?php
    if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
      {
      //send email
      $email = $_REQUEST['email'] ; 
      }
    else
    //if "email" is not filled out, display the form
      {
      echo "<form method='post' action='mailform.php'>
      Email: <input name='email' type='text' /><br />
      <input type='submit' />
      </form>";
      }
    ?>
    Last edited by davidjmorin; 01-15-2008 at 02:31 PM.

Bookmarks

Posting Permissions

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