Jump to content

Forms


2RIP

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.
Link to comment
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?
Link to comment
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]
Link to comment
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.
Link to comment
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]
Link to comment
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?
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.