revo Posted February 29, 2008 Share Posted February 29, 2008 Okay I'm new here and kinda new to PHP coding so I don't know if this is where to post it. What I'm looking for is a script to email certain addresses, like what I want is someone to fill out a form and put their email address with out the @domain.tld, I want that as a drop down menu and when they submit it, it will email that address. I have looked at some tutorials but all of them show you have to put in your email address but I want it to be so the user will get the email when they fill in the email address and select the drop down email account. Any and all help is appreciated! If you need any more information or I didn't explain it full please let me know. Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 29, 2008 Share Posted February 29, 2008 ok if your looking to code this yourself, youve come to the right place! if your looking for a premade script try the snippets forum or http://www.hotscripts.com or similar. http://www.phpfreaks.com/forums/index.php/board,41.0.html if your looking for someone to code this for you go to the freelancing forum. http://www.phpfreaks.com/forums/index.php/board,8.0.html can you confirm if your willing to code this yourself? cheers, Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted February 29, 2008 Share Posted February 29, 2008 how are you planning on emailing them if you don't know the @domain.ext part of the email address? you need to store the full email address in a database, and then take the email string and replace everything in the email address starting with the @ symbol with "" (nothing) and then make that appear in the drop down box and then make a script to email to that address when the form is submitted. if you don't know anything about php it will take you a while. Quote Link to comment Share on other sites More sharing options...
revo Posted March 1, 2008 Author Share Posted March 1, 2008 I am willing to code it myself since I don't have anything to offer (I just now [like 5 minutes ago] got a speeding ticket. ). I am okay with HTML a little rusty (I have not coded in like 3 or so years.) I'm not as good with PHP however. This is what I have so far: <?php $subject="test"; $message="test"; if (!isset($_POST["send"])){ // no post data, display form ?> <form method="post" action="email.php"> Phone Number: <input name="phonenumber" type="text" /><br /><br /> Carrier: <select name="carrier"> <option value="" selected>Carrier</option> <option value="@message.alltel.com" >Alltel</option> <option value="@txt.att.net" >AT&T/Cingular</option> <option value="@metropcs.sms.us" >Metro PCS</option> <option value="@messaging.sprintpcs.com" >Sprint</option> <option value="@tmomail.net" >T Mobile</option> <option value="@vtext.com" >Verizon</option> </select><br /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /> </form> <?php }else{ // found post data $to=$_POST['phonenumber']&['carrier']; // send mail : if (mail($to,$subject,$message,"From: $from\n")){ // success echo "Mail sent successfully to $to. "; }else{ // failure echo "Doh ! Sending failed. "; } } ?> I get an error on line 28: "$to=$_POST['phonenumber']&['carrier'];" Now I'm sure thats not how it is so posed to be and I'm going to get flamed for it but I'm a n00b I know this. Now I saved it as email.php. I guess what im really asking is how do add two variables or strings? together? Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted March 1, 2008 Share Posted March 1, 2008 try $to=$_POST['phonenumber'] . $_POST['carrier']; (when you connect to variables together as one string, you need to use a period) Quote Link to comment Share on other sites More sharing options...
revo Posted March 1, 2008 Author Share Posted March 1, 2008 Thanks for the fast replay! But I'm still getting an error on line 28: Parse error: syntax error, unexpected '[' in /home/revo/public_html/email.php on line 28 Edit: Ok I saw you edited it with a new code will try it! Edit 2: Okay that work.. well sorta I get no errors but it does not sent the message. I erased the first $message="test" to see maybe that had something to do with it but still nothing. After I hit Submit it's as if the page refreshes. Now like I said I'm new to PHP so correct me if I'm wrong but when you hit Submit shouldn't it display "Mail sent successfully to $to." or "Doh ! Sending failed." and not the form? Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted March 1, 2008 Share Posted March 1, 2008 in the form, change the submit button to this: <input type="submit" name="send" value="Send" /> Quote Link to comment Share on other sites More sharing options...
revo Posted March 3, 2008 Author Share Posted March 3, 2008 Well I was not near a pc till now but thanks so much!! Everything works!! If anyone wants/needs the idea for anything be my guest! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.