Log in

View Full Version : drop down email list



davidjmorin
01-09-2008, 02:10 AM
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:

<?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>

BLiZZaRD
01-09-2008, 02:39 AM
<?
$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.

davidjmorin
01-11-2008, 02:24 PM
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..

alexjewell
01-15-2008, 11:49 AM
I had to do something similar with a form I had. I'll show you the javascript, then the form example:



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.



<script type="text/javascript" src="emailOther.js"></script>


Now, here's how you would use it on the form:



<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:


#other_input{
display: none;}


If you have any questions, let me know.

davidjmorin
01-15-2008, 02:25 PM
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



<?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



<?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>";
}
?>