It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) |
|
Senior Member
|
Not sure if this will be useful to anyone, but maybe the explinations will help some people with the workings of PHP.
This is how you send a form via a PHP script. Ok, the first thing you need is the form. Which will be made with HTML. In this form, we will ask for a name, email and comment. Code:
<form action='send.php' method='post'> Name: <input type='text' name='name' /><br /><br /> E-Mail: <input type='text' name='email' /><br /><br /> Comment: <textbox name='comment' cols='50' rows='5'></textbox><br /><br /> <input type='submit' value='Send' name='submit' /> </form> Code:
form action='send.php' Code:
method='post' Code:
name='email' where that comes up later in the PHP script. Ok, onto the PHP script needed to send the information. Code:
<?php
//Check to see if the submit button was hit
if (!isset($_POST['submit'])) {
echo "You did not submit the form";
} else {
//Assign each submitted information to a variable
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
//Assign the mail variables
$subject = "Form Submitted";
$message = "Name: $name\n\n E-mail: $email\n\n $content";
$your_email = "youremail@domain.com";
//send the mail
mail($your_email, $subject, $message);
//Tell the user that the email was successful and redirect them
echo "E-mail sent, thanks for your feedback<br />Redirecting...";
echo "<META HTTP-EQUIV = 'Refresh' Content = '2; URL = index.php'>";
}
?>
Code:
if (!isset($_POST['submit'])) Code:
$name = $_POST['name']; $email = $_POST['email']; $comment = $_POST['comment']; Code:
//Assign the mail variables $subject = "Form Submitted"; $message = "Name: $name\n\n E-mail: $email\n\n $content"; $your_email = "youremail@domain.com"; //send the mail mail($your_email, $subject, $message); Code:
//PHP comments And that is about all. If any part of it doesn't make sense to you just post here and i'll try to further explain Copyright, Gaia of Eternal Realm
__________________
http://eternal-realm.net/images/sigs/knife.gif http://img304.imageshack.us/img304/4...rlpower9rm.jpg Do we have to die for love or do we love to die? Please don't Instant Message or Private Message me for graphic requests. If you want a graphic made go to this forum and someone will surely help you out. For those who give a %*#$ |
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Do I use MY WEBSITE'S email when submitting to Dmoz? | bailey | All Other SE's & Directories | 2 | 08-28-2008 05:35 PM |
| Listing of Business Forms... | Evolution Graphics | General Business Issues | 3 | 09-01-2006 12:33 AM |
| Search Engine Optimization Considerations before submitting your site | jordan | Search Engine Optimization | 0 | 07-28-2006 03:01 PM |
| Are there compatibility issues between ASP.NET and mobile Web forms? | Nazir | .NET | 0 | 07-25-2006 10:28 AM |
| Looping through forms items | clayton | ASP | 0 | 07-08-2006 06:23 PM |