Jump to content

Archived

This topic is now archived and is closed to further replies.

2RIP

Forms

Recommended Posts

Well this question relates mostly to html.

How can i make a form that will send to my email?
not the <form action="mailto:email@host.com">

Maybe it posts in a cgi file first. Sorry i'm not sure what i'm doing because i don't know where to start first or how to make this.

Share this post


Link to post
Share on other sites
<form action="script.php">

Then, script.php should process data and send it, with mail() or something like:

[a href=\"http://www.php.net/mail\" target=\"_blank\"]http://www.php.net/mail[/a]

Share this post


Link to post
Share on other sites
so for the script.php, this is what i would enter?:

SMTP mail()
smtp_port
sendmail_from
sendmail_path

Is that all that is required, or is there more to it. Also how would i turn it into the correct format of a script.. sorry i'm new to php codes. Can someone give examples of how it should look like?

Share this post


Link to post
Share on other sites
No, but this shoud extract all data sent to the script and send it to your email:

[code]<?php

$to = 'youremail@yourdomain.com';
$subject = 'This is a message';
$message = "Message : \n\n";

foreach ($_POST as $key => $value) {
   $message .= $key . ': ' . $value . "\n";
}

mail($to, $subject, $message);

?>[/code]

Obviously you need:

[code]<form action="script.php" method="post">[/code]

Share this post


Link to post
Share on other sites
Thanks you very much, i got it work now.

And one more question(for now that is [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] )
How can i make it redirect to another page, since it becomes blank after submitting it.

Share this post


Link to post
Share on other sites
After mail($to, $subject, $message); you can add a Location header:

[code]header("Location: http://www.sompage.com");[/code]

Or a link:

[code]echo 'Email Sent!<br />
<a href="somepage.htm">Redirect</a>';[/code]

Or even display a page:

[code]echo file_get_contents('somepage.htm');[/code]

Share this post


Link to post
Share on other sites
Oh yes, i was going to ask you in the previous post, but i forgot.

How can i set text in boxes required. So theres no spamming of submission. And if i have a form with Age option in it, how can i set it so visitors are required to enter ##s instead of alphabet?

Share this post


Link to post
Share on other sites
you would make if statements on the posted variables, like

if (isset($_POST['blah'] && $_POST['blah'] != ' ' && is_numeric($_POST['blah'])) {
.
.
}

although with age, you might do better to have a dropdown box. that way the user can only select pre-formatted values. that is, they would HAVE to choose 1-100 or whatever, instead of entering in lkasf for age.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.