Jump to content

Forms


2RIP

Recommended Posts

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

[code]<?php

$to = '[email protected]';
$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
https://forums.phpfreaks.com/topic/11944-forms/#findComment-45339
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
https://forums.phpfreaks.com/topic/11944-forms/#findComment-45349
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
https://forums.phpfreaks.com/topic/11944-forms/#findComment-45353
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
https://forums.phpfreaks.com/topic/11944-forms/#findComment-45392
Share on other sites

Archived

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

×
×
  • 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.