Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Html][PHP]Polaczenie formularza
Forum PHP.pl > Forum > Przedszkole
kasiamilion
Witam serdecznie !

Z tego tytulu ze jestem laikiem w temacie bardzo bym prsila Panowie o pomoc.
Potrzebuje polaczyc formularz w pliku z html z plikiem php - tak by wypelnione pola z formularza wysylane byly na mojego maila.

Dodam ze serwer i domene posiadam w nazwa.pl

Skrypt znalazlam - nazywa sie dynaform14

Po sprawdzeniu skryptu jest napisane ze zainstalowano popranie - niesetety po wypelnieniu i wyslaniu wyskakuje blad: DynaForm Error - Invalid Domain
You have accessed DynaForm from an external domain - this is not allowed.
Mam wpisaen swoj adres mail na domenie (serwerze ktory wyglada jak np: majka@majka.pl)
Ponizej w spoilerze kod z html:

CODE
<form action="dynaform.php" method="POST">
<input type='hidden' name='rec_mailto' value='stickero@stickero.pl' />
<input type='hidden' name='rec_subject' value='New DynaForm Email' />
<input type='hidden' name='rec_thanks' value='thanks.html' />
<div class="form_description">
<h2>Book a cleaner</h2>
<p>Please fill the form below.</p>
</div>
<ul >

<li id="li_1" >
<label class="description" for="element_1">Name </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_3" >
<label class="description" for="element_3">Adress </label>
<div>
<input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_4" >
<label class="description" for="element_4">Postcode </label>
<div>
<input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_6" >
<label class="description" for="element_6">Home Phone </label>
<div>
<input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_7" >
<label class="description" for="element_7">Mobile Phone </label>
<div>
<input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_8" >
<label class="description" for="element_8">E-mail </label>
<div>
<input id="element_8" name="element_8" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_9" >
<label class="description" for="element_9">Hours per Week </label>
<div>
<input id="element_9" name="element_9" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_5" >
<label class="description" for="element_5">Bedrooms </label>
<div>
<select class="element select small" id="element_5" name="element_5">
<option value="" selected="selected"></option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5+</option>

</select>
</div>
</li> <li id="li_10" >
<label class="description" for="element_10">Bathrooms </label>
<div>
<select class="element select small" id="element_10" name="element_10">
<option value="" selected="selected"></option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5+</option>

</select>
</div>
</li> <li id="li_11" >
<label class="description" for="element_11">Reception </label>
<div>
<select class="element select small" id="element_11" name="element_11">
<option value="" selected="selected"></option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5+</option>

</select>
</div>
</li> <li id="li_12" >
<label class="description" for="element_12">Levels </label>
<div>
<select class="element select small" id="element_12" name="element_12">
<option value="" selected="selected"></option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4+</option>

</select>
</div>
</li> <li id="li_13" >
<label class="description" for="element_13">Ironing services ? </label>
<span>
<input id="element_13_1" name="element_13" class="element radio" type="radio" value="1" />
<label class="choice" for="element_13_1">Yes</label>
<input id="element_13_2" name="element_13" class="element radio" type="radio" value="2" />
<label class="choice" for="element_13_2">No</label>

</span>
</li> <li id="li_15" >
<label class="description" for="element_15">Are there any pets ? </label>
<span>
<input id="element_15_1" name="element_15" class="element radio" type="radio" value="1" />
<label class="choice" for="element_15_1">Yes</label>
<input id="element_15_2" name="element_15" class="element radio" type="radio" value="2" />
<label class="choice" for="element_15_2">No</label>

</span>
</li> <li id="li_14" >
<label class="description" for="element_14">Cleaner have a keys ? </label>
<span>
<input id="element_14_1" name="element_14" class="element radio" type="radio" value="1" />
<label class="choice" for="element_14_1">Yes</label>
<input id="element_14_2" name="element_14" class="element radio" type="radio" value="2" />
<label class="choice" for="element_14_2">No</label>

</span>
</li> <li id="li_2" >
<label class="description" for="element_2">Other informations </label>
<div>
<textarea id="element_2" name="element_2" class="element textarea small"></textarea>
</div>
</li>

<li class="buttons">
<input type="hidden" name="form_id" value="365833" />

<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>



Prosze o pomoc !

Pamietajcie ze dzis Dzien Kobiet tongue.gif

A i zapomnialam o kodzie PHP (nie mzmiescil sie w edycji):

CODE
CODE
<?

\
// ###########################################################################





$from_address = "";

$required_on = "no";

$required_errorpage = "error.html";

$override = "no";

$incoming_mailto = "stickero@stickero.pl";

$incoming_subject = "Nowe zlecenie ze strony";

$incoming_thanks = "thanks.html";

$ban_ip_on = "no";


$ban_ip_list = "111.222.33.55,11.33.777.99";

$secure_domain_on = "yes";






$autorespond_on = "no";

$autorespond_subject = "Your Form Submission";


$autorespond_from = "youremail@yoursite.com";


$autorespond_contents = "Your submission from our website has been received. Thank you!";


$autorespond_mailto_field = "Email";

if($HTTP_SERVER_VARS['REQUEST_METHOD'] == "GET") {
echo "
<html>
<head><title>Webligo PHP DynaForm is installed correctly.</title></head>
<body>
<font style='font-family: verdana, arial; font-size: 9pt;'>
<b>DynaForm is installed correctly.</b></font><br>
<font style='font-family: verdana, arial; font-size: 8pt;'>
DynaForm Easy PHP Form Mailer was created by <a href='http://www.webligo.com'>Webligo Developments</a>.
</font>
</body></html>
";
exit();
}

// SET VARIABLES
$incoming_fields = array_keys($HTTP_POST_VARS);
$incoming_values = array_values($HTTP_POST_VARS);

if($override == "no") {
$incoming_mailto = @$HTTP_POST_VARS['rec_mailto'];
$incoming_subject = @$HTTP_POST_VARS['rec_subject'];
$incoming_thanks = @$HTTP_POST_VARS['rec_thanks'];
}

$incoming_mailto_cc = @$HTTP_POST_VARS['opt_mailto_cc'];
$incoming_mailto_bcc = @$HTTP_POST_VARS['opt_mailto_bcc'];
$form_url = @$HTTP_REFERER;

// MAKE SURE DYNAFORM IS BEING RUN FROM THE RIGHT DOMAIN
if($secure_domain_on == "yes") {
$form_url_array = parse_url($form_url);
$form_domain = $form_url_array[host];
if($form_domain != $HTTP_SERVER_VARS[HTTP_HOST]) {
echo "<h2>DynaForm Error - Invalid Domain</h2>
You have accessed DynaForm from an external domain - this is not allowed.<br>
You may only submit forms to a DynaForm file that exists on the same domain name.<br>
If you believe to be receiving this message in error, please refer to your readme.txt file.
<br><br>";
$error = "yes";
}
}

// CHECK IF MAILTO IS SET
if($incoming_mailto == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_mailto</b>\" field within the form. This field specifies who the email will
be sent to.
<br><br>
This should look like:<br>
<input type=\"hidden\" name=\"rec_mailto\" value=\"youremail@yoursite.com\">
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}

// CHECK IF SUBJECT IS SET
if($incoming_subject == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_subject</b>\" field within the form. This field specifies the subject of
the email that will be sent.
<br><br>
This should look like:<br>
<input type=\"hidden\" name=\"rec_subject\" value=\"New DynaForm Email\">
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}

// CHECK IF THANKS IS SET
if($incoming_thanks == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_thanks</b>\" field within the form. This field specifies what page the user
will be taken to after they submit the form.
<br><br>
This should look like:<br>
<input type=\"hidden\" name=\"rec_thanks\" value=\"thanks.html\">
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}

// CHECK IF IP ADDRESS IS BANNED
if($ban_ip_on == "yes") {

if(strstr($ban_ip_list, $HTTP_SERVER_VARS[REMOTE_ADDR])) {
echo "<h2>DynaForm Error - Banned IP</h2>
You cannot use this form because your IP address has been banned by the administrator.<br>
";
$error = "yes";
}
}


if($error == "yes") {
exit();
}

// SET EMAIL INTRODUCTION
$message = "This email was received from your DynaForm located at $form_url \n\n";

// LOAD EMAIL CONTENTS
for ($i = 0; $i < count($incoming_fields); $i++) {
if($incoming_fields[$i] != "rec_mailto") {
if($incoming_fields[$i] != "rec_subject") {
if($incoming_fields[$i] != "rec_thanks") {
if($incoming_fields[$i] != "opt_mailto_cc") {
if($incoming_fields[$i] != "opt_mailto_bcc") {

// CHECK FOR REQUIRED FIELDS IF ACTIVATED
if($required_on == "yes") {
$sub = substr($incoming_fields[$i], 0, 2);
if($sub == "r_") {
if($incoming_values[$i] == "" OR !isset($incoming_values[$i]) OR $incoming_values[$i] == " ") {
header("Location: $required_errorpage");
exit();
}}}

// ADD FIELD TO OUTGOING MESSAGE
$message .= "$incoming_fields[$i]:\n$incoming_values[$i]\n\n";
}}}}}}

// SET EMAIL FOOTER
$message .= "\n\nThank you for using our Webligo DynaForm script.\nWe ask that you please link back to our site if you have not already.\nYour use of DynaForm is subject to the license agreement outlined in dynaform.php.\nVisit us at: http://www.webligo.com";

// CLEAR HEADERS
$headers = "";

// ADD FROM ADDRESS
if($from_address != "") {
$headers .= "From: $from_address\r\n";
}

// CHECK FOR CC OR BCC
if($incoming_mailto_cc != "") {
$headers .= "Cc: $incoming_mailto_cc\r\n";
}
if($incoming_mailto_bcc != "") {
$headers .= "Bcc: $incoming_mailto_bcc\r\n";
}

// SEND EMAIL
mail($incoming_mailto, $incoming_subject, $message, $headers);

// SEND AUTO-RESPONSE IF ACTIVATED
if($autorespond_on == "yes") {
$autorespond_mailto = @$HTTP_POST_VARS[$autorespond_mailto_field];
$autorespond_headers = "From: $autorespond_from";
mail($autorespond_mailto, $autorespond_subject, $autorespond_contents, $autorespond_headers);
}

// FORWARD TO THANK YOU PAGE
header("Location: $incoming_thanks");


?>
jaslanin
Ten kod wygląda na b. stary. (używa $HTTP_REFERER i HTTP_POST_VARS które są przestarzałe w PHP5)

Poszukaj jakiegoś nowszego formularza kontaktowego np.

http://codechirps.com/php-email-contact-form-tutorial/
kasiamilion
W takim razie pomogl by mi Pan w napisaniu kodu do tego formularza (w html ktory juz jest gotowy) ?
kasiamilion
A dlaczego majac takie formularz w html:
CODE
<form class="email" action="mailer.php" method="post">
<p>Name:<input type="text" name="name" /></p>
<p>Adress:<input type="text" name="adress" /></p>
<p>Postcode:<input type="text" name="postcode" /></p>
<p>Home Phone:<input type="text" name="homephone" /></p>
<p>Mobile Phone:<input type="text" name="mobilephone" /></p>
<p>Work Phone:<input type="text" name="workphone" /></p>
<p>E-mail:<input type="text" name="email" /></p>
<p>Other informations:</p>
<textarea name="message"></textarea></p>
<input class="send" type="submit" value="Send">


i taki skrypt php:

CODE
<?php
/* Set e-mail recipient */
$myemail = "stickero@stickero.pl";

/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "Enter your name");
$adress = check_input($_POST['adress'], "Enter a adress");
$postcode = check_input($_POST['postcode'], "Enter a postcode");
$homephone = check_input($_POST['homephone'], "Enter a Home Phone");
$mobilephone = check_input($_POST['mobilephone'], "Enter a Mobile Phone");
$workphone = check_input($_POST['workphone'], "Enter a Work Phone");
$email = check_input($_POST['email']);
$message = check_input($_POST['message'], "Write your message");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "

Name: $name

Adress: $adress

Postcode: $postcode

Homephone: $homephone

Mobilephone: $mobilephone

Workphone: $workphone

E-mail: $email

Message:
$message

";

/* Send the message using mail() function */
mail($myemail, $name, $adress, $message, $postcode, $homephone, $mobilephone, $email, $workphone , $message
);

/* Redirect visitor to the thank you page */
header('Location: thanks.html');
exit();

/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($myError)
{
?>
<html>
<body>

<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>

</body>
</html>
<?php
exit();
}
?>


Po wpisaniu danych nic nie dochodzi na mial ?/ wczesniej przy mniejszej iloscidanych (sam message name i email) nie bylo z tym problemu ?
d3ut3r
pierwsze co rzuca się w oczy to:

  1. mail($myemail, $name, $adress, $message, $postcode, $homephone, $mobilephone, $email, $workphone , $message
  2. );


powinno raczej wyglądać tak:

  1.  
  2. mail($myemail,'Temat emaila',$message);
  3.  
peter13135

  1. mail($myemail, $name, $adress, $message, $postcode, $homephone, $mobilephone, $email, $workphone , $message
  2. );


Z tego co mi wiadomo, funkcja mail() ma 4 parametry, w tym jeden opcjonalny.
Tutaj przekazywanych jest 10 argumentów, więc od razu wiadać, że to "może nie zadziałać".

na php.net jest taka funkcja / przykład jak wysłać maila z polskimi znakami :
  1. <?php
  2. function plmail($mail, $sub, $mes){
  3. $headers = "From: ExRobot <robot@example.com>\r\n";
  4. $headers .= "MIME-Version: 1.0\r\n";
  5. $headers .= "Content-type: text/plain; charset=utf-8\r\n";
  6. $headers .="Content-Transfer-Encoding: 8bit";
  7.  
  8. $mes=htmlspecialchars_decode($mes,ENT_QUOTES);//optional - I use encoding to POST data
  9. mail($mail, "=?utf-8?B?".base64_encode($sub)."?=", $mes, $headers);
  10. }
  11. ?>


użycie zdaje się być takie :
  1. plmail('odbiorca@example.com', 'tytuł', 'tresc');



W bardziej rozbudowanych systemach lepiej byłó by skorzystać z PHPmailera (moim zdaniem).
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.