2dogs Posted December 25, 2008 Share Posted December 25, 2008 This is probably show how much of a noob I am But here goes! Is there a way I can enter on the form the e-mail address I want the form data to be e-mailed to? ??? Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/ Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 Sure, but not sure why you want to, since the purpose of a Email Form is to not show that, IMO. Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723445 Share on other sites More sharing options...
2dogs Posted December 25, 2008 Author Share Posted December 25, 2008 It's for pulling information from a db and e-mailing to people you want! I got it so I pull the info and send it to myself but I want to be able to send it to others also.. My brother just sent me this link.. Cracks me up..Check it out.. http://www.aksalser.com/game.htm btw my high score is 12 Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723447 Share on other sites More sharing options...
redarrow Posted December 25, 2008 Share Posted December 25, 2008 Take a look at this, You can send if you add the email php function, emails to all users shown from the database. In this example i have used a array for the email's, It shows you the user's emails, and let you send them a default message to all shown emails. That once you add the email php function, and set the database while loop up. <?php if(isset($_POST['submit'])){ $email=$_POST['email']; $email_message=$_POST['email_message']; for($i=0; $i<count($email); $i++){ echo "$email[$i] <br>$email_message<br><br>"; } } $a=array("[email protected]","[email protected]","[email protected]"); echo"<center> <form method='POST' action=' '> Sending these email from the database to the following users: <br><br> </center>"; foreach($a as $key=>$database_emails){ echo "<center> $key <input type='text' name='email[]' value='$database_emails'> <br> </center>"; } echo"<center> <br><br> <textarea name='email_message' cols='40' rows='10'>Please write your message......</textarea> <br><br> <input type='submit' name='submit' value='submit'> </center>"; ?> Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723451 Share on other sites More sharing options...
redarrow Posted December 25, 2008 Share Posted December 25, 2008 added a bit more security, Let you only send email's if it a yes, selected beside the email name from the array. <?php if(isset($_POST['submit'])){ $ansaw=$_POST['ansaw']; $email=$_POST['email']; $email_message=$_POST['email_message']; for($i=0; $i<count($email); $i++, $ansaw++){ if($ansaw[$i]=="yes"){ echo "$email[$i] <br>$email_message $ansaw[$i]<br><br>"; } } } $a=array("[email protected]","[email protected]","[email protected]"); echo"<center> <form method='POST' action=' '> Sending these email from the database to the following users: <br><br> <b>Send email yes or no!</b></center>"; foreach($a as $key=>$database_emails){ echo "<center> <input type='text' name='email[]' value='$database_emails'> <select name='ansaw[]'> <option value='no'>No <option value='yes'>Yes </select> <br> </center>"; } echo"<center> <br><br> <textarea name='email_message' cols='40' rows='10'>Please write your message......</textarea> <br><br> <input type='submit' name='submit' value='submit'> </center>"; ?> Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723459 Share on other sites More sharing options...
redarrow Posted December 25, 2008 Share Posted December 25, 2008 WARNING please only let admin's use this code, or every one will send your user's emails from your database. I went the full mile and added database info. read the comments ok. This code will let anybody who needs it, Send a default message, to all the emails in the database via selecting yes. I have not added the php email function, as that your job for fun. <?php //add database connection. //$sql=mysql_connect("localhost","username","password"); //$res=mysql_select_db("database_name",$sql)or die(mysql-error()); if(isset($_POST['submit'])){ $ansaw=$_POST['ansaw']; $email=$_POST['email']; $email_message=$_POST['email_message']; for($i=0; $i<count($email); $i++, $ansaw++){ if($ansaw[$i]=="yes"){ //Add the php mail function here. // The $to would be email[$i] of the email function. //and the $message of the email function would be $email_message echo "$email[$i] <br>$email_message $ansaw[$i]<br><br>"; } } } //get rid of this if using a database. $a=array("[email protected]","[email protected]","[email protected]"); echo"<center> <form method='POST' action=' '> Sending these email from the database to the following users: <br><br> <b>Send email yes or no!</b></center>"; //select example //$sql1="select* from users"; //$res1=mysql_query($sql1)or die(mysql_error()); //while($row=mysql_fetch_assoc($res1)){ //$database_emails=$row['user_emails']; //get rid of the foreah if using database. foreach($a as $key=>$database_emails){ echo "<center> <input type='text' name='email[]' value='$database_emails'> <select name='ansaw[]'> <option value='no'>No <option value='yes'>Yes </select> <br> </center>"; } //get rid off this foreach loop end if your using a database. //} end of while loop, use if using database. echo"<center> <br><br> <textarea name='email_message' cols='40' rows='10'>Please write your message......</textarea> <br><br> <input type='submit' name='submit' value='submit'> </center>"; ?> Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723462 Share on other sites More sharing options...
2dogs Posted December 25, 2008 Author Share Posted December 25, 2008 Thanks for adding the comments, I wanted to use a sql db The wife is getting upset I need to stop having fun.. Thanks for all your help! Link to comment https://forums.phpfreaks.com/topic/138357-e-mail-form-question/#findComment-723488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.