2RIP Posted June 14, 2006 Share Posted June 14, 2006 Well this question relates mostly to html.How can i make a form that will send to my email?not the <form action="mailto:email@host.com">Maybe it posts in a cgi file first. Sorry i'm not sure what i'm doing because i don't know where to start first or how to make this. Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/ Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 <form action="script.php">Then, script.php should process data and send it, with mail() or something like:[a href=\"http://www.php.net/mail\" target=\"_blank\"]http://www.php.net/mail[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45331 Share on other sites More sharing options...
2RIP Posted June 14, 2006 Author Share Posted June 14, 2006 so for the script.php, this is what i would enter?:SMTP mail()smtp_portsendmail_fromsendmail_pathIs that all that is required, or is there more to it. Also how would i turn it into the correct format of a script.. sorry i'm new to php codes. Can someone give examples of how it should look like? Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45337 Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 No, but this shoud extract all data sent to the script and send it to your email:[code]<?php$to = 'youremail@yourdomain.com';$subject = 'This is a message';$message = "Message : \n\n";foreach ($_POST as $key => $value) { $message .= $key . ': ' . $value . "\n";}mail($to, $subject, $message);?>[/code]Obviously you need:[code]<form action="script.php" method="post">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45339 Share on other sites More sharing options...
2RIP Posted June 14, 2006 Author Share Posted June 14, 2006 Thanks you very much, i got it work now.And one more question(for now that is [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] )How can i make it redirect to another page, since it becomes blank after submitting it. Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45349 Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 After mail($to, $subject, $message); you can add a Location header:[code]header("Location: http://www.sompage.com");[/code]Or a link:[code]echo 'Email Sent!<br /><a href="somepage.htm">Redirect</a>';[/code]Or even display a page:[code]echo file_get_contents('somepage.htm');[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45353 Share on other sites More sharing options...
2RIP Posted June 14, 2006 Author Share Posted June 14, 2006 Oh yes, i was going to ask you in the previous post, but i forgot.How can i set text in boxes required. So theres no spamming of submission. And if i have a form with Age option in it, how can i set it so visitors are required to enter ##s instead of alphabet? Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45391 Share on other sites More sharing options...
.josh Posted June 14, 2006 Share Posted June 14, 2006 you would make if statements on the posted variables, like if (isset($_POST['blah'] && $_POST['blah'] != ' ' && is_numeric($_POST['blah'])) {..}although with age, you might do better to have a dropdown box. that way the user can only select pre-formatted values. that is, they would HAVE to choose 1-100 or whatever, instead of entering in lkasf for age. Quote Link to comment https://forums.phpfreaks.com/topic/11944-forms/#findComment-45392 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.