Jump to content


Photo

Forms


  • Please log in to reply
7 replies to this topic

#1 2RIP

2RIP
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 June 2006 - 02:24 AM

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.

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 14 June 2006 - 02:29 AM

<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]
~ D Kuang

#3 2RIP

2RIP
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 June 2006 - 03:03 AM

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?


#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 14 June 2006 - 03:21 AM

No, but this shoud extract all data sent to the script and send it to your email:

<?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);

?>

Obviously you need:

<form action="script.php" method="post">

~ D Kuang

#5 2RIP

2RIP
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 June 2006 - 04:04 AM

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.

#6 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 14 June 2006 - 04:09 AM

After mail($to, $subject, $message); you can add a Location header:

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

Or a link:

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

Or even display a page:

echo file_get_contents('somepage.htm');

~ D Kuang

#7 2RIP

2RIP
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 June 2006 - 06:36 AM

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?

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 14 June 2006 - 06:41 AM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users