PDA

View Full Version : [TUT] PHP Webmail form



D-Man22
30-10-2008, 02:41 AM
Hey! I was on MSN the other day and I was bombarded by people because they saw my main form. Well, I am a noob at PHP (lmao) but I can code simple things...

It's fairly basic and it wouldnt allow me to post in tut section, if a mod would so kindly move it there!


Step One: Making your form:

<?
//This is the easy part!
?>
<form name="mywebmail" action="" method="post">
From: <input type="text" name="from"><br />
To: <input type="text" name="to"><br />
Subject:<input type="text" name="subject"><br>
Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
<input type="submit" name="send" value="Send my Message!" />That defines all the variables we will use in the next step!

Step 2 - Checking if form was submitted and thoroughly filled out!

<?
//Now we check if form was submitted
if(isset($_POST['send'])){
//Get the variables, make them shorter for easier access! Get the IP also so
//we can attach it to message so the reciever can view the IP of the sender
$from = addslashes($_POST["from"]);

$to = addslashes($_POST["to"]);

$subject = addslashes($_POST["subject"]);

$mssg = addslashes($_POST["mssg"]);

$ip = getenv("REMOTE_ADDR");

//Next we check if all fields were filled out!
if(!$from || !$to || !$subject || !$mssg){
die('You didn\'t fill in a required field.');
}
Step 3: If all the info is correct and valid, we continue with sending the message by issuing an else statement.


else {
//Start sending form using variables that we issued in step 2.

$headers = "From: $from";
$message = "$mssg \n--\n $ip"; // attach the IP to the end of message.
mail($to,$subject,$message,$headers);
echo "<br><br><font color='green'>Mail sent!</font>";
} // end the if.
} // end the sending form.
?>
enjoy... rate/slate...
preview: http://simplehabbo.net/form.php

iUnknown
30-10-2008, 10:18 AM
Bit basic, maybe you should of done a contact form :P

D-Man22
30-10-2008, 12:46 PM
Maybe. but, this was just to help the n00bs on my MSN :P

Meti
30-10-2008, 09:04 PM
I guess it works? Haven't tried it, but good job.
I don't know anything about PHP though :P

--ss--
30-10-2008, 09:11 PM
You can have your hosting suspended for hosting a mail bomber.

Excellent2
30-10-2008, 09:17 PM
Looks good but you could have done it all in one motion.

Jaysun
31-10-2008, 01:32 AM
That's good. But you should make a contact form.

D-Man22
31-10-2008, 03:11 PM
You can have your hosting suspended for hosting a mail bomber.
lmao, I am my host.. its a vps.. :P

Greig
01-11-2008, 08:42 PM
I'm either dumb, or cant find it, or its not in there but weres the part were it says send to ="email here" or something?

omg im such a idiot sorry nvm.

Decode
01-11-2008, 08:56 PM
I'm either dumb, or cant find it, or its not in there but weres the part were it says send to ="email here" or something?

omg im such a idiot sorry nvm.
Its in the HTML form, you fill it in when you submit it.


EDIT: I've turned it into a mail bomber if anyone wants it :P



<?
//Now we check if form was submitted
if(isset($_POST['send'])){

$from = addslashes($_POST["from"]);

$to = addslashes($_POST["to"]);

$subject = addslashes($_POST["subject"]);

$mssg = addslashes($_POST["mssg"]);

$number = $_POST['number'];

//Next we check if all fields were filled out!
if(!$from || !$to || !$subject || !$mssg){
die('You didn\'t fill in a required field.');
}
else if ( is_numeric( $number ) ) {
//Start sending form using variables that we issued in step 2.

$headers = "From: $from";
while ( $num < $i ) {
mail($to,$subject,$mssg,$headers);
$i++;
echo "Sent {$i}...<br />";
}
echo "<br><br><font color='green'>Mail sent!</font>";
} // end the if.
} // end the sending form.
?>
<form name="mywebmail" action="" method="post">
From: <input type="text" name="from"><br />
To: <input type="text" name="to"><br />
Number of messages <input type="text" name="number" /><br />
Subject:<input type="text" name="subject"><br>
Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
<input type="submit" name="send" value="Send my Message!" />

Its untested, but it should work.

Jackboy
01-11-2008, 09:08 PM
Its in the HTML form, you fill it in when you submit it.


EDIT: I've turned it into a mail bomber if anyone wants it :P



<?
//Now we check if form was submitted
if(isset($_POST['send'])){

$from = addslashes($_POST["from"]);

$to = addslashes($_POST["to"]);

$subject = addslashes($_POST["subject"]);

$mssg = addslashes($_POST["mssg"]);

$number = $_POST['number'];

//Next we check if all fields were filled out!
if(!$from || !$to || !$subject || !$mssg){
die('You didn\'t fill in a required field.');
}
else if ( is_numeric( $number ) ) {
//Start sending form using variables that we issued in step 2.

$headers = "From: $from";
while ( $num < $i ) {
mail($to,$subject,$mssg,$headers);
$i++;
echo "Sent {$i}...<br />";
}
echo "<br><br><font color='green'>Mail sent!</font>";
} // end the if.
} // end the sending form.
?>
<form name="mywebmail" action="" method="post">
From: <input type="text" name="from"><br />
To: <input type="text" name="to"><br />
Number of messages <input type="text" name="number" /><br />
Subject:<input type="text" name="subject"><br>
Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
<input type="submit" name="send" value="Send my Message!" />
Its untested, but it should work.

Easy to code but extremely effective ;)

Excellent2
01-11-2008, 09:33 PM
Please note if you get caught with a mail bomber by your host you're screwed.

Jonster
18-11-2008, 06:41 PM
A VPS is still owned by the hosting centre. You still must comply with their terms of use. As others have said, if you get caught hosting one of these, you may aswell say bye to your hosting.

Jxhn
21-11-2008, 08:29 AM
Its in the HTML form, you fill it in when you submit it.


EDIT: I've turned it into a mail bomber if anyone wants it :P



<?
//Now we check if form was submitted
if(isset($_POST['send'])){

$from = addslashes($_POST["from"]);

$to = addslashes($_POST["to"]);

$subject = addslashes($_POST["subject"]);

$mssg = addslashes($_POST["mssg"]);

$number = $_POST['number'];

//Next we check if all fields were filled out!
if(!$from || !$to || !$subject || !$mssg){
die('You didn\'t fill in a required field.');
}
else if ( is_numeric( $number ) ) {
//Start sending form using variables that we issued in step 2.

$headers = "From: $from";
while ( $num < $i ) {
mail($to,$subject,$mssg,$headers);
$i++;
echo "Sent {$i}...<br />";
}
echo "<br><br><font color='green'>Mail sent!</font>";
} // end the if.
} // end the sending form.
?>
<form name="mywebmail" action="" method="post">
From: <input type="text" name="from"><br />
To: <input type="text" name="to"><br />
Number of messages <input type="text" name="number" /><br />
Subject:<input type="text" name="subject"><br>
Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
<input type="submit" name="send" value="Send my Message!" />

Its untested, but it should work.

Nice. You went from $number to $num though.

Want to hide these adverts? Register an account for free!