Jump to content
Fórum Script Brasil
  • 0

(Resolvido) Formulário de contato e/ou reserva


marcel26

Question

Baixei recentemente um tutorial de como criar um formulário em php, já havia feito alguns, mas como estava dando erro resolvi reler para ver se tinha algum erro. Talvez esteja desatualizado, alguém pode me ajudar?

Segue o código abaixo:

--- sendmail.php

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$country = $_POST['country'];
$inparty = $_POST['inparty'];
$arrival = $_POST['arrival'];
$departure = $_POST['departure'];
$request = $_POST['request'];


$msg = "<font face=’Verdana’ size=’3'><b>Reservation Form</b></font><br><hr><p>";
$msg .= "<font face=’Verdana’ size=’1'><b>Name:</b><font color=#ff0000> \t$name</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>E-mail:</b><font color=#ff0000> \t$email</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Telephone:</b><font color=#ff0000> \t$telephone</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Country:</b><font color=#ff0000> \t$country</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Inparty:</b><font color=#ff0000> \t$inparty</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Arrival date:</b><font color=#ff0000> \t$arrival</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Departure:</b><font color=#ff0000> \t$departure</font></font><br>";
$msg .= "<font face=’Verdana’ size=’1'><b>Request:</b><font color=#ff0000> \t$request</font></font><br>";

$mensagem = "$msg";
$rem = "$email";
$dest = "marcelmouta@gmail.com";
$subject = "Rio Apartments Rental: Reservation Form";
$headers = "From:  $email <$name>";
if(!mail($dest,$subject,$mensagem,$headers)){
print "Sorry, your e-mail was not sent.";
} else {
echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=http://www.rioapartmentsrental.com/email_sucess.html'>";

}
?>
--- reserva.html
<p>
    <form action="sendmail.php" method="post">

        Name:<br /> <input type="text" name="name" size=70/><br/>
        E-mail:<br /> <input type="text" name="email" size=70/><br/>
        Phone:<br /> <input type="text" name="telephone" size=70/><br/>
        Country:<br /> <input type="text" name="country" size=70/><br/>
        In party:<br /> <input type="text" name="inparty" size=70/><br/>
        Arrival date / Time:<br /> <input type="text" name="arrival" size=70/><br/>
        Departure date / Time:<br /> <input type="text" name="departure" size=70/><br/>
        Select an apartment or penthouse:<br/>
        <select name="reservethis"><option name="copacabana">Copacabana</option>
        <option name="02bedroomscopacabana">--- 02 bedrooms oceanfront</option> 
        <option name="03bedroomsoceanview">--- 03 bedrooms oceanview</option>
        <option name="03bedroomsoceanfront">--- 03 bedrooms oceanfront</option>
        <option name="penthousecopacabana">--- Penthouse</option>
        <option name="ipanema">Ipanema</option>
        <option name="03bedroomsoceanfront">--- 03 bedrooms oceanfront</option>
        <option name="03bedroomsoceanview">--- 03 bedrooms oceanview</option>
        <option name="04bedroomsupperclass">--- 04 bedrooms upper class</option>
        <option name="penthouseipanema">--- Penthouse</option>
        </select><br/>
        Request and comments:<br /> <textarea name="comments" cols="50" rows="8" size=80></textarea><br/>
        <input type="submit" value="Send" /> <input type="reset" value="Clear" />

    </form>
</p>

Tem algum erro no código pois recebo os e-mails assim, cheio de erros.

<font face=’Verdana’ size=’3'><b>Reservation Form</b></font><br><hr><p><font face=’Verdana’ size=’1'><b>Name:</b><font color=#ff0000> Leticia Ayala</font></font><br><font face=’Verdana’ size=’1'><b>E-mail:</b><font color=#ff0000> xxxxxxx@hotmail.com</font></font><br><font face=’Verdana’ size=’1'><b>Telephone:</b><font color=#ff0000> 555 21 5874157</font></font><br><font face=’Verdana’ size=’1'><b>Country:</b><font color=#ff0000> </font></font><br><font face=’Verdana’ size=’1'><b>Comments and request:</b><font color=#ff0000> </font></font><br>

Agradeço desde já qualquer ajuda que seja

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Faltou especificar no cabeçalho que o e-mail conterá HTML...

Troque isso:

$headers = "From: $email <$name>";

Por isso:

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $email <$name>\r\n";

Deve resolver...

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.6k
×
×
  • Create New...