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:
That defines all the variables we will use in the next step!PHP Code:<?
//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!" />
Step 2 - Checking if form was submitted and thoroughly filled out!
Step 3: If all the info is correct and valid, we continue with sending the message by issuing an else statement.PHP Code:<?
//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.');
}
enjoy... rate/slate...PHP Code: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.
?>
preview: http://simplehabbo.net/form.php





Reply With Quote







