chey Posted July 3, 2006 Share Posted July 3, 2006 hello, i need some help with PHP. in fact, i know NUTS about PHP, and my asp knowledge has been returned to my teacher 2 years ago.anyway, i need some basics first. my aim is to configure a command in a form, and when the form is validated, to actually send my email add the contents of the form.sounds a bit too much for a beginner, but can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/ Share on other sites More sharing options...
hackerkts Posted July 3, 2006 Share Posted July 3, 2006 Need more details about it. Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-52354 Share on other sites More sharing options...
chey Posted July 4, 2006 Author Share Posted July 4, 2006 ok, right now i have this form here below...[URL=http://img136.imageshack.us/my.php?image=anjel30ok.jpg][IMG]http://img136.imageshack.us/img136/9052/anjel30ok.th.jpg[/img][/URL]and i just need to make sure when i click the 'subscribe' button, there would be an email sent to me. Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-52722 Share on other sites More sharing options...
.josh Posted July 4, 2006 Share Posted July 4, 2006 okay your form should look something similar to this:[code]<form action = 'somewhere.php' method = 'post'> Name: <input type = 'text' name='name'><br> Email: <input type = 'text' name='email'><br> <input type = 'submit' value='subscribe' name='submit'></form>[/code]okay so in somewhere.php you would have this:[code]<?php if ($_POST['submit']) { mail ('youremailaddress.com','subject here','message here'); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-52773 Share on other sites More sharing options...
chey Posted July 5, 2006 Author Share Posted July 5, 2006 ok, i can understand that... but the problem is, currently the form is linked to a js, that is, when submit is clicked, the data inserted will go to a database through the js function which looks like this.[code] function submitcombutton() { var form = document.mosForm; // do field validation if (form.name.value == "") { alert( "<?php echo _REGWARN_NAME;?>" ); } else if (form.email.value == "") { alert( "<?php echo _REGWARN_MAIL;?>" ); } else { form.submit(); } }[/code]then, this is the front end side[code]<form method="post" action="<?php echo sefRelToAbs('index.php?option=com_anjel&Itemid=' . $Itemid . '&action=unregistered&task=addUnregistered'); ?>" name="mosForm" > <table align="center" border="0" cellpadding="0" cellspacing="3"> <tr> <td align="center"><?php echo _INPUT_NAME; ?></td> <td><input type="text" name="name" value="" class="inputbox" /></td> </tr> <tr> <td align="center"><?php echo _INPUT_EMAIL; ?></td> <td><input type="text" name="email" value="" class="inputbox" /></td> </tr> <?php foreach ($letters as $letter) {?> <tr> <td align="right"><input type="checkbox" name="<?php echo $letter->id; ?>" value="1" class="inputbox" /></td> <td><span class="anjel_letter_names"><?php echo mosToolTip(addslashes(htmlentities($letter->list_desc)), addslashes(htmlentities($letter->list_name)), '', '', addslashes(htmlentities($letter->list_name)), '#', 1); ?></span></td> <td> </td> </tr><?php } // end foreach?> <tr> <td align="right"><input type="checkbox" name="receivehtml" value="1" class="inputbox" /></td> <td><?php echo _RECEIVE_HTML; ?></td> </tr> <tr> <td> </td> <td><input type="button" value="<?php echo _SUBSCRIBE; ?>" class="button" onclick="submitcombutton()" /> </td> </tr> </table> </form>[/code]so how am i supposed to implement these 2 codings together? Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-53164 Share on other sites More sharing options...
chey Posted July 6, 2006 Author Share Posted July 6, 2006 i managed to get the email to be generated. but now i need help with changing the name of the person sending the email. it gives me a funny address. how do i do so???also, the 'message here', i want the message in my email to look something like this:You have a new subscriber:Name: (name entered)Email: (email entered)i am not good with this php stuff, but so far, the code was:[code]if ($result) { echo '<p>' . _UNREGISTEREDADDED . '</p>';[/code]and i added[code]mail ('myemail','New Subscriber For Newsletter','You Have a New Unregistered Subscriber:<br /> Name:'name'<br /> Email:'email'<br />');[/code]now, my problem is the last '', where that is what would appear in the email. so i need help with that only. the email is sent fine. Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-53789 Share on other sites More sharing options...
kenrbnsn Posted July 6, 2006 Share Posted July 6, 2006 The line you showed for the mail() function is incorrect. It is much better to put all the information into variables:[code]<?php$to = 'your@email.address.here';$subject = 'New Subscriber For Newsletter';$body = "You Have a New Unregistered Subscriber:\n";$body .= "Name: $nameEntered\n";$body .= "Email: $emailEntered\n";$headers = "From: $to\n";mail($to,$subject,$body,$headers);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-53801 Share on other sites More sharing options...
chey Posted July 7, 2006 Author Share Posted July 7, 2006 thanks a lot for you help! every thing goes thru, except the name now. *headdesks*i really appreciate the help... though my php knowledge still sucks.thanks once again ken :) Quote Link to comment https://forums.phpfreaks.com/topic/13514-help-with-php/#findComment-54211 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.