Dafydd Posted January 2, 2007 Share Posted January 2, 2007 Hello! I'm working on a php form that's supposed to send the text written/options chosen in the form boxes as an e-mail. I would greatly appreciate it if someone could give me a brief explanation of how to make the php form send an email when a certain button is clicked by the visitor. Everything in the form is done - the boxes are there, error messages appear upon clicking "submit" if a box has been left blank, etc. All I need is the e-mail thingy. Any good links to tutorials on the matter? Quote Link to comment Share on other sites More sharing options...
Doulifée Posted January 3, 2007 Share Posted January 3, 2007 <?$email = $_GET['email'] ;$message = $_GET['message'] ;mail( "yourname@example.com", "Email Subject", $message, "From: $email" );print "Congratulations your email has been sent";?> something like that? sendmail()is the php fonction. Quote Link to comment Share on other sites More sharing options...
Dafydd Posted January 6, 2007 Author Share Posted January 6, 2007 The following post contains all of the code for the page. Upon clicking submit, now, what happens is I get a "The requested method POST is not allowed for the URL" error. I think this code uses asp or something and it's supposed to use php. I'm not sure, but it's something about the server not supporting the script this was written in. I'm guessing this: <!--webbot BOT="GeneratedScript" endspan --> <form method="POST" name="FrontPage_Form1" action="index.htm" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" webbot-action="--WEBBOT-SELF--"> is what's causing the problem? The "index.htm" is the file that contains this code, I'm guessing that's a bad idea, but I don't really know what I should put there instead. Quote Link to comment Share on other sites More sharing options...
Dafydd Posted January 17, 2007 Author Share Posted January 17, 2007 <html> <head> <title>Söka till kören</title> </head> <body class="normal"> <table border="0" cellpadding="0" cellspacing="0" width="700"> <tr> <td width="11" height="27"> </td> <td width="600" valign="top"> <p class="rubrik1"> <span style="letter-spacing: 2pt"> <b> SÖK TILL UPPSALA KAMMARKÖR </b> </span> </p> </td> <td width="89" align="right" valign="top"> <p class="rubrik1"> <span style="letter-spacing: 2pt"> <b> <input type="button" value="Ångra" onClick="history.go(-1)";> </b> </span> </p> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="700"> <tr> <td width="11"> </td> <td width="689" valign="top"> <p class="MsoNormal"> <span style="mso-ansi-language:SV"> <font size="2"> Uppsala Kammarkör söker erfarna körsångare till samtliga stämmor. </font> </span> </p> <p class="normal" style="margin-bottom: 3"> <font size="2"> Fyll i formuläret nedan så kontaktar vi dig. Kören tillämpar inträdesprov. Vid inträdesprovet sjunger du en sång efter eget val som presenterar din röst på ett bra sätt. Om du vill ha pianoackompanjemang går det oftast att ordna. Glöm inte att ta med extra noter till ackompanjatören! Ackord- och melodigehör testas, likaså notläsning och röstens omfång. Vi avslutar med ett ensembleprov (där du tillsammans med tre av körens representanter bildar en kvartett) och en kort intervju. Då finns också tillfälle att ställa frågor om kören och dess verksamhet. </font> </p> <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --> <script Language="JavaScript" Type="text/javascript"> <!-- function FrontPage_Form1_Validator(theForm) { if (theForm.Namn.value == "") { alert("Vänligen fyll i ditt förnamn!"); theForm.Namn.focus(); return (false); } if (theForm.efternamn.value == "") { alert("Vänligen fyll i ditt efternamn!"); theForm.efternamn.focus(); return (false); } if (theForm.Telefon.value == "") { alert("Vänligen fyll i ditt telefonnummer!"); theForm.Telefon.focus(); return (false); } if (theForm.stamma.selectedIndex < 0) { alert("Vänligen välj en stämma!"); theForm.stamma.focus(); return (false); } if (theForm.stamma.selectedIndex == 0) { alert("Vänligen välj en stämma!\nAlternativet \"Ange stämma\" är inget giltigt val."); theForm.stamma.focus(); return (false); } return (true); } //--> </script> <!--webbot BOT="GeneratedScript" endspan --> <form method="POST" name="FrontPage_Form1" action="index.htm" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" webbot-action="--WEBBOT-SELF--"> <!--webbot bot="SaveResults" s-label-fields="TRUE" b-reverse-chronology="FALSE" s-email-format="TEXT/PRE" b-email-label-fields="TRUE" b-email-replyto-from-field="TRUE" s-email-replyto="Epost" b-email-subject-from-field="FALSE" s-email-subject="Anmälan till sångprov" s-builtin-fields="REMOTE_NAME REMOTE_USER" s-form-fields="Namn efternamn Telefon age gatuadress stamma postadress Epost tidigare_korerfarenhet musikalisk_bakgrund stanna sysselsattning " u-confirmation-url="tack.htm" s-email-address="dahe9761@student.uu.se" U-File="../../../_private/rekrytering_vt07.csv" S-Format="TEXT/CSV" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan i-checksum="43374" --> <table border="0" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="678" id="AutoNumber1"> <tr> <td width="13%" class="normal"> <font size="2"> Förnamn* </font> </td> <td width="32%" class="normal"> <font size="2"> <!--webbot bot="Validation" s-display-name="Namn" b-value-required="TRUE" --> <input type="text" name="Namn" size="25"> </font> </td> <td width="13%" class="normal"> <font size="2"> Efternamn* </font> </td> <td width="42%" class="normal"> <font size="2"> <!--webbot bot="Validation" s-display-name="Namn" b-value-required="TRUE" --> <input type="text" name="efternamn" size="25"> </font> </td> </tr> <tr> <td class="normal"> <font size="2"> Telefon* </font> </td> <td class="normal"> <font size="2"> <!--webbot bot="Validation" s-display-name="Telefonnummer" b-value-required="TRUE" --> <input type="text" name="Telefon" size="25"> </font> </td> <td class="normal"> <font size="2"> Ålder </font> </td> <td class="normal"> <font size="2"> <select size="1" name="age"> <option>Ange ålder</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> <option>32</option> <option>33</option> <option>34</option> <option>35</option> <option>36</option> <option>37</option> <option>38</option> <option>39</option> <option>40</option> <option>41+</option> </select> </font> </td> </tr> <tr> <td class="normal"> <font size="2"> Gatuadress </font> </td> <td class="normal"> <font size="2"> <input type="text" name="gatuadress" size="25"> </font> </td> <td class="normal"> <font size="2"> Stämma* </font> </td> <td class="normal"> <font size="2"> <!--webbot bot="Validation" b-value-required="TRUE" b-disallow-first-item="TRUE" --> <select size="1" name="stamma"> <option>Ange stämma</option> <option>Sopran 1</option> <option>Sopran 2</option> <option>Alt 1</option> <option>Alt 2</option> <option>Tenor 1</option> <option>Tenor 2</option> <option>Bas 1</option> <option>Bas 2</option> </select> </font> </td> </tr> <tr> <td class="normal"> <font size="2"> Postadress </font> </td> <td class="normal"> <font size="2"> <input type="text" name="postadress" size="25"> </font> </td> <td class="normal"> <font size="2"> e-post </font> </td> <td class="normal"> <font size="2"> <input type="text" name="Epost" size="25"> </font> </td> </tr> <tr> <td colspan="2" class="normal"> <font size="2"> Hur länge planerar du att stanna i Uppsala? <br> </font> </td> <td colspan="2" class="normal"> <font size="2"> <select size="1" name="stanna"> <option>1 termin</option> <option>1 år</option> <option selected>2 år</option> <option>3 år eller mer</option> </select> </font> </td> </tr> <tr> <td colspan="4" class="normal"> <font size="2"> Tidigare körerfarenhet & musikalisk bakgrund: <br> <textarea name="tidigare_korerfarenhet" cols="91" rows="4" class="normal"> </textarea> </font> </td> </tr> <tr> <td colspan="4" class="normal"> <font size="2"> Övriga upplysningar <br> <textarea name="musikalisk_bakgrund" cols="91" rows="4" class="normal"> </textarea> </font> </td> </tr> <tr> <td colspan="4" class="normal"> <font size="2"> Nuvarande sysselsättning (om studier, i vad?) <br> <input type="text" name="sysselsattning" size="90"> </font> </td> </tr> </table> <p class="normal" align="center"> <font size="2"> * = obligatoriska fält </font> </p> <p class="normal" align="center"> <font size="2"> <input type="submit" value=" OK " name="B1"> eller <input type="button" value="Tillbaka" onClick="history.go(-1)";> </font> </p> </form> </td> </tr> </table> </body></html> Quote Link to comment Share on other sites More sharing options...
Doulifée Posted January 17, 2007 Share Posted January 17, 2007 i just see html and java code? where is the php code in there? other thing a php code must be contained in a .php file Quote Link to comment Share on other sites More sharing options...
Sir_NutS Posted January 17, 2007 Share Posted January 17, 2007 do not redirect the form to an html page, otherwise the server won't treat it as php code. Try redirecting it to a php paeg, with the send email code in it. Quote Link to comment Share on other sites More sharing options...
Dafydd Posted January 20, 2007 Author Share Posted January 20, 2007 Sounds like a good idea. I'll try that. Thanks! Though, what is this new php page supposed to contain? The code that doulifee posted in #2? That one doesn't contain a sendmail() though, does it? ... I'm so confused about all this. EDIT: I got help and it works now. Thanks! 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.