php mail

Status
Not open for further replies.

nightscream

New Member
Messages
948
Reaction score
0
Points
0
I have a problem with my php script, it should send a mail when someone clicks the submit button, i've added the name="sumbit" to the submit button but it won't send an email, I think it has to do with the isset command.

here is my code:
PHP:
<?
if(isset($_POST['submit'])) {
    $headers = "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    
    $message = "Naam: ".$_POST['naam']." ".$_POST['voornaam']."<br />";
    $message .= "Email: ".$_POST['e-mail']."<br />";
    $message .= "Telefoon: ".$_POST['telefoon']."<br />";
    $message .= "Adres: ".$_POST['adres']."<br /><br />";
    $message .= "Bericht:<br />".$_POST['bericht'];

    if(mail("pipo1568@hotmail.com","Uitstappen", $message, $headers)) {
    ?>
        <script language="javascript">
        alert("Het bericht is met succes verzonden.")
        </script>
    <?
    }else {
    ?>
        <script language="javascript">
        alert("Er is een fout opgetreden, probeer nog eens of contaceer de beheerder.")
        </script>
    <?
    }
}
?>
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
Can we see the HTML form please? You haven't posted that; and it sounds like the issue is with the submit button on that form. It should be:

Code:
<input type="submit" value="send" />

-Luke.
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
There's two kinds of buttons on a <form> element:
<input type="button" /> and <input type="submit" />. The first one is often used to trigger client-side scripts and such, while the submit is used to submit the form. (obviously)
For example a form
HTML:
<form action="page.php" method="post">
<input type="text" name="input1" value="none" />
<input type="button" name="button1" value="button" />
<input type="submit" name="submit1" value="submit" />
</form>
If the user would press button1, nothing happens. If the user presses submit1, the contents of the form (in this case the values of the 3 <input>'s) are submitted to "page.php" with method "post".

- Marshian

offtopic: Een belg! Ö
 

nightscream

New Member
Messages
948
Reaction score
0
Points
0
Lol, I'm not stupid ;) I've done this a lot but I can't see what the problem is :S

my form
HTML:
 <form method="post" action ="<? $_SERVER['PHP_SELF']; ?>" enctype="text/plain">
                    <table>
                        <tr>
                            <td><label for="naam">Naam:</label></td>
                            <td><input type="text" name="naam:" id="naam" size="15" maxlength="40"/></td>
                        </tr>
                        <tr>
                            <td><label for="voornaam">Voornaam:</label></td>
                            <td><input type="text" name="voornaam" id="voornaam" size="15" maxlength="40"/></td>
                        </tr>
                        <tr>
                            <td><label for="e-mail">E-mail:</label></td>
                            <td><input type="text" name="e-mail" id="e-mail" size="20" maxlength="60"/></td>
                        </tr>
                        <tr>
                            <td><label for="telefoon">Telefoon:</label></td>
                            <td><input type="text" name="telefoon" id="telefoon" size="15" maxlength="15"/></td>
                        </tr>
                        <tr>
                            <td><label for="adres">adres:</label></td>
                            <td><input type="text" name="adres" id="adres" size="30" maxlength="50"/></td>
                        </tr>
                        <tr>
                            <td valign="top"><label for="bericht">Bericht:</label></td>
                              <td><textarea rows="8" cols="50" name="bericht" id="bericht">Typ hier je mail</textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2"><input type="submit" name="submit" value="Verstuur"/></td>
                    </table>
                    </form>
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Your main problem is enctype="text/plain". It would be enctype="application/x-www-form-urlencoded"(unless you're uploading files), but that's the default so you don't need to specify it. You can delete that attribute.

Another small problem is that you need to have print or echo before $_SERVER['PHP_SELF'] so that the value gets placed there. An empty action usually means to post to the current page, so it does work the way it is. That's probably why you didn't notice that issue.
 
Last edited:

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
As this has been solved, I'll close it.

-Luke.

* Thread Closed *
 
Status
Not open for further replies.
Top