Jump to content

very new to php and having problems. I need help.


jan23778

Recommended Posts

Hi everyone,

 

I have only just started to follow some php tutorials and seem to have hit a brick wall. I am writing some basic php form processing code for a friends website (well actually following a tutorial and adjusting it slightly to fit my needs) and it just doesn't seem to work properly. Here is the html I am using:

 

 <form action="form.php" method="post" class="contact">

        <fieldset>

         

          <div>

            <label for="contactname" class="fixedwidth">Nombre y Apellido</label>

            <input type="text" name="contactname" id="contactname"/>

          </div>

          <div>

            <label for="telephone" class="fixedwidth">Numero de Telefono</label>

            <input type="text" name="telephone" id="telephone"/>

          </div>

          <div>

            <label for="email" class="fixedwidth">Correo Electronico</label>

            <input type="text" name="email" id="email"/>

          </div>

          <div>  

              <label for="tipo" class="fixedwidth">Tipo de Seguro</label>

              <select name="tipo" id="tipo">     

                <option>Rodaje de spots</option>

                <option>Sesiones de Fotografía</option>

                <option>Cortometrajes</option>     

                <option>Otros suguros</option>  

              </select> 

            </div>

            <div>

              <p>Texto</p>

              <div class="textarea">

              <textarea name="detalles" id="details" cols="30" rows="7"></textarea>

              </div>

<div class="buttonarea">



  <input type="submit" value="Envianos la informacion"/>



</div>

 

and the php:

 

<?php//import form information

$detalles = $_POST['detalles'];
$tipo = $_POST['tipo'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$contactname = $_POST['contactname'];

$message=stripslashes($message);

/*
Simple form validation
check to see if an email and message were entered
*/
//if no message entered and no email entered print an error
if (empty($message) && empty($email)){
print "No email address and no message was entered. <br>Please include an email and a message";
}
//if no message entered send print an error
elseif (empty($message)){
print "No message was entered.<br>Please include a message.<br>";
}
//if no email entered send print an error
elseif (empty($email)){
print "No email address was entered.<br>Please include your email. <br>";
}
//if the form has both an email and a message
else {

//Thank the user by name if they entered a name
if (!empty($name)) {
print "<b>Thank you $name.</b><br>";
}

print "<p><b>The following message has been sent</b>: <br>$message<br></p><p><b>Comment type(s):</b><br>$screen_ctypes</p>";
$body= $message . ' Comment type(s)' . $ctypes;

//mail the form contents
mail( "jan_colombini@hotmail.com", "Web site comments", $body, "From: $email\r\n" );

$page = "http://www.elisegur.es/contact.html";
if (!ereg($page, $_SERVER['HTTP_REFERER'])){
echo "Invalid referer";
die;
}
}
?>

 

It does send the info to my email address but has the following problems (by the way I am sorry to make it more difficult as it is half in Spanish but please be patient I have only been doing this a few days):

 

The information is not always sent at all.

 

On sending the information it shows "the following information has been sent: ...then the message in the box" have I done the following code wrong?

 

if (!empty($name)) {

print "<b>Thank you $name.</b><br>";

 

either way the message in the box never arrives at my email address.

 

In fact the only info that does arrive is the name and email address.

 

I hope someone can help as I am really desperate to get the hang of php and to help my friend with his website but am just finding it so frustrating.

 

I am sorry if this is very basic for you guys but would really appreciate and suggestion and help you can give.

 

Thanks

 

 

 

 

Link to comment
Share on other sites

Hi Revraz,

 

That was a really quick reply. Thank you.

 

Do you mean to change the "mail the form contents" section to this:

 

//mail the form contents

mail( "jan_colombini@hotmail.com", "Web site comments", $body, "From: $jan_colombini@hotmail.com\r\n" )

Link to comment
Share on other sites

Hi revraz, thank you again for your reply.

 

I am not 100% sure where the message variable would go, I am still very new and finding it difficult. My best guess would be the following:

 

$detalles = $_POST['detalles'];

$tipo = $_POST['tipo'];

$telephone = $_POST['telephone'];

$email = $_POST['email'];

$contactname = $_POST['contactname'];

$message = $_POST['message'];

 

$message=stripslashes($message);

 

However I thought the text area was covered by the $detalles = $_POST['detalles']; array as that is what i have named it in the sheet?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

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