Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Ne radi mi forma za slanje e-maila!

[es] :: PHP :: Ne radi mi forma za slanje e-maila!

[ Pregleda: 2162 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

tamnicar
sremska mitrovica

Član broj: 54010
Poruke: 67
195.252.85.*



Profil

icon Ne radi mi forma za slanje e-maila!06.07.2005. u 10:33 - pre 229 meseci
posto sam nov u PHP-u (naravno ne nov u programiranju) imam jedan problem!
precesljao sam ovaj forum u potrazi za skriptom u PHP-a koja radi slanje popunjene forme na e-mail!
te sam na ovome forumu video link:
http://www.totallyphp.co.uk/scripts/form_to_mail.htm
kod je:

Code:

<?php

/**
 * Change the email address to your own.
 *
 * $empty_fields_message and $thankyou_message can be changed
 * if you wish.
 */

// Change to your own email address
$your_email = "[email protected]";

// This is what is displayed in the email subject line
// Change it if you want
$subject = "Message via your contact form";

// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";

// This is displayed when the email has been sent
$thankyou_message = "<p>Thankyou. Your message has been sent.</p>";

// You do not need to edit below this line

$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);

if (!isset($_POST['txtName'])) {

?>

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">

    <p><label for="txtName">Name:</label><br />
    <input type="text" title="Enter your name" name="txtName" /></p>

    <p><label for="txtEmail">Email:</label><br />
    <input type="text" title="Enter your email address" name="txtEmail" /></p>

    <p><label for="txtMessage">Your message:</label><br />
    <textarea title="Enter your message" name="txtMessage"></textarea></p>

    <p><label title="Send your message">
    <input type="submit" value="Send" /></label></p>

</form>

<?php

}

elseif (empty($name) || empty($email) || empty($message)) {

    echo $empty_fields_message;

}

else {

    // Stop the form being used from an external URL
    // Get the referring URL
    $referer = $_SERVER['HTTP_REFERER'];
    // Get the URL of this page
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
    // If the referring URL and the URL of this page don't match then
    // display a message and don't send the email.
    if ($referer != $this_url) {
        echo "You do not have permission to use this script from another URL.";
        exit;
    }

    // The URLs matched so send the email
    mail($your_email, $subject, $message, "From: $name <$email>");

    // Display the thankyou message
    echo $thankyou_message;
    
}

?>

jedino sto sam naravno u promenljivoj $your_email stavio [email protected]
takvu stranicu sam postavio na (free PHP hosting server)
www.bokica.siteburg.com
ali kada popunim sve i stisnem send izbaci mi error da se stranica ne nalazi na njihovom server-u???
pogledajte molim vas code i mozete otici na site koji sam dao pa probajte! ne znam sta ne valja!!!

p.s.
trazio sam po ovom forumu resenje ali ga nisam nasao! ako je kojim slucajem bilo vec opisano ja se izvinjavam sto ponovo pitam!
 
Odgovor na temu

broker

Član broj: 2415
Poruke: 8514
212.62.59.*



+11 Profil

icon Re: Ne radi mi forma za slanje e-maila!06.07.2005. u 10:43 - pre 229 meseci
Problem i je verovatno u ovome.

Code:
    
    $referer = $_SERVER['HTTP_REFERER'];
    // Get the URL of this page
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];


Proveri koje vrednostiimaju $referer i $this_url, posto izgleda da server ne daje tacne informacije pa se ne poklapa na proveri.

Nekuovakvu proveru moras imati, jer tako otezavas nekom zlonamernim da zloupotrebi skript za spamovanje.
 
Odgovor na temu

tamnicar
sremska mitrovica

Član broj: 54010
Poruke: 67
195.252.85.*



Profil

icon Re: Ne radi mi forma za slanje e-maila!06.07.2005. u 10:59 - pre 229 meseci
ne znam u cemu je problem ja izbrisem taj daeo koda i ono opet mi pokazuje da se stranica ne nalazi na serveru!!!
izbrisem ovo
Code:

// Stop the form being used from an external URL
    // Get the referring URL
    $referer = $_SERVER['HTTP_REFERER'];
    // Get the URL of this page
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
    // If the referring URL and the URL of this page don't match then
    // display a message and don't send the email.
    if ($referer != $this_url) {
        echo "You do not have permission to use this script from another URL.";
        exit;
    }
 
Odgovor na temu

SmilieBG
Aleksandar Skodric
NL

Član broj: 13094
Poruke: 1821
*.speed.planet.nl.



+3 Profil

icon Re: Ne radi mi forma za slanje e-maila!06.07.2005. u 11:35 - pre 229 meseci
bolje ti je da krenes od pocetka sam formu da pravis i da je saljes...

kreni od jednostavnih stvari, kao na primer, prvo samo sibni mail, bez forme, dakle:

mail($to,$subject,$body,$optional_headers);

pa onda dodaj da ti $to salje iz forme, pa lagano izgradjuj. Takodje, meni je preglednije ako su forma i sama skripta za slanje odvojeni u 2 fajla, ali...

Poz,
Sale
=========
Uporedi cene i karakteristike za vise od 10.000 proizvoda, izmedju ostalog:
Digitalni foto-aparati
Mobilni telefoni
Skolski pribor
=========
 
Odgovor na temu

tamnicar
sremska mitrovica

Član broj: 54010
Poruke: 67
195.252.85.*



Profil

icon Re: Ne radi mi forma za slanje e-maila!07.07.2005. u 09:06 - pre 229 meseci
hvala pokusacu!
rekao si
Citat:
Takodje, meni je preglednije ako su forma i sama skripta za slanje odvojeni u 2 fajla


jel to ovo:
Code:

<?
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.example.com/feedback.html" );
  }
  elseif (empty($email) || empty($message)) {
    header( "Location: http://www.example.com/error.html" );
  }
  else {
    mail( "[email protected]", "Feedback Form Results",
      $message, "From: $email" );
    header( "Location: http://www.example.com/thankyou.html" );
  }
?>

<form method="post" action="sendmail.php">
Email: <input type="text" name="email" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>

ovo sam skinuo sa net-a, samo sto napocetku moram da dodam posle <? i <? php :kez
 
Odgovor na temu

[es] :: PHP :: Ne radi mi forma za slanje e-maila!

[ Pregleda: 2162 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.