|
Posted by Robin on 09/10/07 08:39
Lammi wrote:
> i assume you wanna get the form via email? thescript below will give
> you a text-formatted email, listing all fields and the given values.
>
> <?php
>
> if (isset($_POST['Send']))
>
>
> $to = 'you@email.com';
> $subject = 'Request from Website';
>
> $myEmail = "A new request was sent:\n";
> foreach ($_POST as $key => $value)
> $myEmail .= $key.". ".$value."\n";
>
> mail ($to, $subject, $myEmail);
> ?>
>
> <form class="cssform" action="<? $_SERVER['PHP_SELF'] ?>">
> <p>
> <label for="user">Name:</label>
> <input type="text" name="user" id="user" value="" />
> </p>
> <p>
> <label for="emailaddress">Email Address:</label>
> <input type="text" name="emailadress" id="emailaddress"
> value="" />
> </p>
> <p>
> <label for="phone">Phone Number:</label>
> <input type="text" name="phone" id="phone" value="" />
> </p>
> <p>
> <label for="call">Best Time To Call:</label>
> Morning:
> <input type="radio" name="call" />
> Afternoon:
> <input type="radio" name="call" />
> Night
> <input type="radio" name="call" />
> </p>
> <p><label for="call">Subject:</label>
> <select name="web">
> <option selected value="Quote">Quote</option>
> <option value="Tech Support">Tech Support</option>
> </option>
> </select>
> <br><br><br>
> <p><label for="comments">Comments:</label>
> <textarea name="comments" rows="" cols=""></textarea>
>
> <div style="margin-left: 150px;">
> <input type="submit" value="Submit" name="Send" />
> <input type="reset" value="Reset" name="Reset" />
> </div>
>
> do some</form>
>
You will need a { after the if and a } after the mail().
I would do some validation of the POST data before sending possibly
malicious data to myself.
Note that Lammi added name="xxx" to the input tags (you cannot use just
id="xxx" they aren't the same thing).
Also, he added a value for the action attribute of the form, though
using $_SERVER['PHP_SELF'] is no longer considered a good idea due to
XSS exploits.
Navigation:
[Reply to this message]
|