Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Email-redirect form


ghost's Avatar
0 0

I need a form, when it's submitted the data needs to go to my email client and the page needs to be redirected.


function mailMe( form ) {
        // put some checks here
        return true;
}

</script>
<form action="mailto:fredje138@gmail.com" method="POST"
enctype="text/plain" name="email"
onsubmit="return mailMe( this.form )">
    <p align="center">Name:<br>
    <input type="text" size="30" name="filled by"><br>
    kom je (ja/nee)<br>
    <input type="text" size="30" name="komst "
    value="ja"><br>
    E-mail:<br>
    <input type="text" size="30" name="EMAIL ADRESS"><br>
    <input type="submit" value="Submit "></font></p>
</form>```
This one sends the data to my email but doesnt redirect and it asks to be sent or not, I want it to be sent without notice and afterwards redirected to another site. Is it possible?
If the submitting to email without notice isnt possible then submitting to a web page, that only I can view, is ok too. PHP can do the trick too, just dunno how :P

Help is appreciated.
thx!

ghost's Avatar
0 0
<?php

if(isset($_POST["submit"]))
{
     $frm = $_POST["name"]." <".$_POST["email"].">";
     mail("fredje138@gmail.com", "The Subject", $_POST["msg"], "From: $frm");
     echo "<meta http-equiv=\"refresh\"content="0; url=page_to_redirect_to.php\">
}  

else
{
?>
<form method="POST" enctype="text/plain" name="email" action="<?=$_SERVER["PHP_SELF"]; ?>">

<p align="center">
Name:<br>
<input type="text" size="30" name="name"><br><br>

Email Address:<br>
<input type="text" name="email"><br><br>

Message:<br>
<input type="text" size="30" name="msg"><br>

<input type="submit" name="submit" value="Submit "></font></p>
</form>
<?php
}
?>

There's a script in PHP that will have them fill out the form with their Name, Email Address, and their Message. Then it will mail the information to you and redirect them page_to_redirect_to.php. Tweak it as necessary. If you need help changing something in this, let me know.

Also, make sure you save this with a "php" extension and upload it to a server that supports PHP.


ghost's Avatar
0 0
if (isset($_POST['Subject']) OR isset($_POST['Body'])) {
$message = wordwrap($_POST['Body'], 70);
mail('fredje138@gmail.com', $_POST['Subject'] , $message);
echo "Message Sent";
} else {
echo "<form action=\"send.php\" method=\"post\">
Subject<input type=\"text\" name=\"Subject\"><br>
Message<input type=\"text\" name=\"Body\"><br>
<input type=\"Submit\" value=\"Send\">
</form>";
}
?>```

rushed, should do the trick.

ghost's Avatar
0 0

Xero wrote:

<?php

if(isset($_POST["submit"]))
{
     $frm = $_POST["name"]." <".$_POST["email"].">";
     mail("fredje138@gmail.com", "The Subject", $_POST["msg"], "From: $frm");
     echo "<meta http-equiv=\"refresh\"content="0; url=page_to_redirect_to.php\">
}  

else
{
?>
<form method="POST" enctype="text/plain" name="email" action="<?=$_SERVER["PHP_SELF"]; ?>">

<p align="center">
Name:<br>
<input type="text" size="30" name="name"><br><br>

Email Address:<br>
<input type="text" name="email"><br><br>

Message:<br>
<input type="text" size="30" name="msg"><br>

<input type="submit" name="submit" value="Submit "></font></p>
</form>
<?php
}
?>

There's a script in PHP that will have them fill out the form with their Name, Email Address, and their Message. Then it will mail the information to you and redirect them page_to_redirect_to.php. Tweak it as necessary. If you need help changing something in this, let me know.

Also, make sure you save this with a "php" extension and upload it to a server that supports PHP.

this one gives this error: Parse error: parse error, unexpected ';' in C:\Program Files\wamp\www\test.php on line 15

willeH wrote:

if (isset($_POST['Subject']) OR isset($_POST['Body'])) {
$message = wordwrap($_POST['Body'], 70);
mail('fredje138@gmail.com', $_POST['Subject'] , $message);
echo "Message Sent";
} else {
echo "<form action=\"send.php\" method=\"post\">
Subject<input type=\"text\" name=\"Subject\"><br>
Message<input type=\"text\" name=\"Body\"><br>
<input type=\"Submit\" value=\"Send\">
</form>";
}
?>```

rushed, should do the trick.

no errors here but, I redirected it to the send.php page and that worked, but i didnt get an email :(

ghost's Avatar
0 0

check you have an smtp server properly set up. Sometimes it does take a while for the email to come through. btw the script worked for me.


ghost's Avatar
0 0

btw you must name the file you save it as to 'send.php' or change the form action to be the new name.


ghost's Avatar
0 0

willeH wrote: check you have an smtp server properly set up. Sometimes it does take a while for the email to come through. btw the script worked for me.

I need to setup an smtp server too? I got WAMP php server set up but that wont do i presume. How do I install a smtp server