Jump to content

Please give me your help with my html/php form


fernandovaz

Recommended Posts

???Need a bit of help. ???

 

I’ trying to complete a form in html and use php function to send it to my email

 

I’ve search the web for a tutorial but as I’m a NOB :-[, I cant get it to work correctly, can someone help me out and show me how this is done ?

 

This is what I’diong so far:

 

<form action=form.php" method="POST" name="contacto form" id="contacto form">

 

<p>Nome:<br>

<input name="nome" type="text" id="nome" size="80">

<p>Empresa:<br>

<input name="empresa" type="text" id="empresa" size="80">

<p>Contacto:<br>

<input name="contacto" type="text" id="contacto" size="30">

<p>Email:<br>

<input name="email" type="text" id="email" size="40">

<p>Assunto:<br>

  <textarea name="assunto" cols="75" rows="10" id="assunto"></textarea>

 

<p><input name="Submit" type="submit" id="Submit" value="Enviar">

  <input type="reset" name="reset" id="reset" value="Apagar" />

                  </form>

 

My “form.php” is:

 

<?php

$Nome = $_POST['nome];

$Nome = $_POST['empresa'];

$Nome = $_POST['contacto'];

$Nome = $_POST['email'];

$Nome = $_POST['assunto'];

 

$to = '[email protected]';

$subject = "pedido de contacto: $topic";

$message = "$nome said: $assunto";

$headers = "From: $email";

 

mail($to, $subject, $message, $headers);

 

header("Location: http://thankyou.html");

 

?>

 

Thanks in advanced for the help

 

Well, you are just resetting the $Nome variable 5 times.

 

$Nome = $_POST['nome'];

$Nome = $_POST['empresa'];

$Nome = $_POST['contacto'];

$Nome = $_POST['email'];

$Nome = $_POST['assunto'];

 

You should change those to 5 different variables. Remember to use the same variable names when referring to them later on.

$Nome = $_POST['nome'];
$Nome = $_POST['empresa'];
$Nome = $_POST['contacto'];
$Nome = $_POST['email'];
$Nome = $_POST['assunto'];

 

and are you connecting to your db anywhere?

 

should beeee

$Nome = $_POST['nome'];
$empresa = $_POST['empresa'];
$contacto = $_POST['contacto'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];

 

should beeee

$Nome = $_POST['nome'];
$empresa = $_POST['empresa'];
$contacto = $_POST['contacto'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];

 

This is great thanks for the help so far, now I can get the field "assunto" to appear in the email sent, btw assunto means message.

 

but I wanted also to see in the email received from the form what people  write in the fields:

nome "(name)", empresa "( location)", etc.

 

Thanks in advanced

This is what I have done so far:

 

<?php
$nome = $_POST['nome'];
$empresa = $_POST['empresa'];
$contacto = $_POST['contacto'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];

$to = '[email protected]';
$subject = "pedido de contacto: $topic";
$message = "$nome said: $assunto";
$message = "$empresa";
$message = "$contacto";
$message = "$email";
$message = "$nome";
$headers = "From: $email";

mail($to, $subject, $message, $headers);

header("Location: http://www.thankyou.html");

?>

 

Unfortunately only the subject line ( $subject = "pedido de contacto: $topic";), and the name (nome) of the person that sends the email appears in the email sent.

 

What shall I do to correct the code and make this work ???

???

Hi I`m a noobie also,  anyway I just completed this script yesterday with the help of other and it works,  it`s similar to what you want, but obviously you`ll have to customize it to your requirements.

You`ll need to create 3 Files named Brochure.php, Sendmail.php & Thankyou.php and post the script as shown below into each appropriate file.

 

Hope this helps (I know how frustrating it is when you just want to complete something, but don`t know where to start !!!)

 

Chris

8)

 

 

 

Brochure Request Form : This is where customer asks for a brochure by giving their details

 

<p><span class="style41">BROCHURE REQUEST FORM </span><span class="style44"><br>

            </span><br>

            <!-- saved from url=(0022)http://internet.e-mail -->

          </p>

      <form name="Brochure" method="post" action="sendmail.php"

onsubmit="return ValidateDate();">

<br>

  <table width="641">

    <tr>

      <td class="style41"><div align="left">Title : </div></td>

      <td><div align="left">

          <select name="title">

            <option value="Mr">Mr

            <option value="Mrs">Mrs

            <option value="Miss">Miss

          </select>

          <br>

      </div></td>

    </tr>

    <tr>

      <td class="style41"> </td>

      <td> </td>

    </tr>

    <tr>

      <td width="275" class="style41"><div align="left">Christian Name :</div></td>

      <td width="354">          <div align="left">

        <input name="christianname" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td><div align="left"><span class="style41">Surname :</span></div></td>

      <td><div align="left">

        <input name="surname" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td> </td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Company Name :</div></td>

      <td><div align="left">

        <input name="company" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Street Address :</div></td>

      <td><div align="left">

        <input name="street" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Town / City :</div></td>

      <td><div align="left">

        <input name="town" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">County :</div></td>

      <td><div align="left">

        <input name="county" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Postcode : </div></td>

      <td><div align="left">

        <input name="postcode" type="text" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Telephone No. :</div></td>

      <td><div align="left">

        <input name="tel" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Fax No. :</div></td>

      <td><div align="left">

        <input name="fax" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Email : </div></td>

      <td><div align="left">

        <input name="email" type="text" maxlength="75" />

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">How did you hear about us : </div></td>

      <td><div align="left">

        <select name="select" size="1">

            <option>World Wide Web</option>

            <option>Mailshot</option>

            <option>Yellow Pages</option>

            <option>Ask Alix</option>

            <option>Kellysearch</option>

            <option>118.com</option>

            <option>Recommendation</option>

            <option>Other</option>

        </select>

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td class="style41"><div align="left">Message :</div></td>

      <td><div align="left">

        <textarea name="message" rows="15" cols="40">

        </textarea>

      </div></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td><input type="submit" /></td>

    </tr>

    <tr>

      <td><div align="left"></div></td>

      <td> </td>

    </tr>

  </table>

  <p><br />

      <br>

            </p>

  </form>

 

 

 

Sendmail.php -  This is the main part of the script, that mails the results of brochure form to your email address (you need to change both mail and Location parts)

<?php

  $title = "Title: " . $_REQUEST['title'] . chr(13) ;

  $christianname = "Christian name: " . $_REQUEST['christianname'] . chr(13) ;

  $surname = "Surname: " . $_REQUEST['surname'] . chr(13) ;

  $company = "Company: " . $_REQUEST['company'] . chr(13) ;

  $street = "Street: " . $_REQUEST['street'] . chr(13) ;

  $town = "Town: " . $_REQUEST['town'] . chr(13) ;

  $county = "County: " . $_REQUEST['county'] . chr(13) ;

  $postcode = "Postcode: " . $_REQUEST['postcode'] . chr(13) ;

  $tel = "Tel: " . $_REQUEST['tel'] . chr(13) ;

  $fax = "Fax: " . $_REQUEST['fax'] . chr(13) ;

  $select = "Select " . $_REQUEST['select'] . chr(13) ;

  $message = "Message: " . $_REQUEST['message'] . chr(13) ;

 

  mail( "[email protected]", "Feedback Form Results",

    $title . $christianname . $surname . $company . $street . $town . $county . $postcode . $tel . $fax . $select . $message, "From: $email" );

  header( "Location: http://ccgi.xxxxxx.xxxxxxxxxx/cgi-bin/thankyou.php?title=".$_REQUEST['title']."&surname=".$_REQUEST['surname']);?>

 

 

Thankyou.php - This is just an acknowledgement to confirm email

 

Hello

            <?php

  echo $_GET["title"] . ". " . $_GET["surname"];?>

            , Thank you for requesting Information, we will send a copy of our<br>

            brochure 

            to you in the post as soon as possible. <br>

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.