PDA

View Full Version : (HELP) About Web form feeback


Marcos
07-22-2012, 05:51 PM
Question: How to send the Form info to my personal email?

Hi all! I have successfully managed to create a form that can register the info intoa .csv file, but, I want it to send to my personal email but I can't figure out what I am doing wrong, I'm still new at this xD, so if you can help me out I would really apreciate it :D.

So here's my script (total)

<html>


<head>
<style type="text/css">


body{
text
width:100%;
padding: 0px 0px 40px 0px

}

ul1
{
list-style-type:none;

padding:0;
}
p {
text-indent: 30px;
}

ul
{
text-align:center;
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;


}
li
{
float:left;
margin:auto;
}
a:link,a:visited
{
display:block;
width:110px;
font-weight:bold;
color:#FFFFFF;
background-color:#0C3;
padding:4px 47px 4px 23px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#0F3;
text-align: center ;

}

body {
background-color:#6F3;
font-family: "Times New Roman", Times, serif;
margin:0;
padding: 0px 0px 30px 0px


}
body,td,th {
font-size: 80%;

}

#div1
{
color:#690;
background-color:#9F3;
margin-left:100px;
height: 100px;
width:1067px;
padding: 60px 0px 320px 0px;
font-family: "Times New Roman", Times, serif;

}
.lol {
font-size: large;
}
.medium {
font-size: medium;
}
.Arial {
font-family: Arial, Helvetica, sans-serif;
}
.Negrito {
font-weight: bold;
text-align: justify;
}
#div1 form table {
font-size: 30px;
}
</style>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">




<img src="House Sale.jpg" alt="House" name="House" width="100%"height="250" align="top" id="House">

<ul>
<li>
<div align="center"><a href="#"></a> </div>
</li>
<li>
<div align="center"><a href="mainpage.php">Home</a>
</li>
<li><a href="#Projects"> </a></li>
<li><a href="Casas.php" title="Lol">Casas</a></li>
<li><a href="#about"></a></li>
<li><a href="#Contact">Contacte</a></li>
<li><a href="#Support"></a></li>

</div>

<li></li>

</ul>
<p>

<div class="Arial" id="div1" >

<form name="input" method="post" action="Contacte.php">
<p>
<table width="60%" border="5" cellspacing="0" cellpadding="5" align="center" >
<tr>
<td><strong>Nome:</strong></td>
<td><input type="text" name="Name" id="Name"></td>
</tr>
<tr>
<td><strong>
<label for="Sobrenome">Sobrenome:</label>
</strong></td>
<td><input type="text" name="Name2" id="Name2"></td>
</tr>
<tr>
<td><strong>
<label for="Número">Número:</label>
</strong></td>
<td><input type="text" name="Número" id="Número"></td>
</tr>
<tr>
<td><strong>
<label for="Email">Email:</label>
</strong></td>
<td><input type="text" name="Email" id="Email"></td>
</tr>
<tr>
<td><strong>Comentário:</strong></td>
<td><textarea name="Comentário" cols="50" rows="7" id="Comentário"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" id="Submit" value="Submit"></td>
</tr>
</table>
</p>
</form>
</div>

<?php
if($_POST['Submit'] == "Submit")
{
$varNome = $_POST['Name'];
$varSobreNome = $_POST['Name2'];
$varNúmero = $_POST['Número'];
$varEmail = $_POST['Email'];
$varComentário = $_POST['Comentário'];
$varEmail = 'Results from Contact form';
$emailadd = 'marcos_lebelini@hotmail.com';

$req = '0';
}

{
$errorMessage = "";
if(empty($_POST['Name']))
{
$errorMessage .= "<li>Introduza o seu nome.</li>";
}

if(empty($_POST['Name2']))
{
$errorMessage .= "<li>Introduza o seu sobrenome.</li>";
}
if(empty($_POST['Número']))
{
$errorMessage .= "<li>Introduza o seu número.</li>";
}
if(empty($_POST['Email']))
{
$errorMessage .= "<li>Introduza o seu email.</li>";
}


$varNome = $_POST['Name'];
$varSobreNome = $_POST['Name2'];
$varNúmero = $_POST['Número'];
$varEmail = $_POST['Email'];

if(!empty($errorMessage))
{
echo("<p>Esqueceu-se de introduzir os seguintes tópicos.</p>\n");
echo("<ul>" . $errorMessage . "</ul>\n");
}
}

if($errorMessage != "")
{
echo("<p>There was an error:</p>\n");
echo("<ul>" . $errorMessage . "</ul>\n");
}
else
{
mail($emailadd, $varEmail, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
exit

?>


</body>
</html>

---------------------------------------------------------------

I want you to focus on this

<?php
if($_POST['Submit'] == "Submit")
{
$varNome = $_POST['Name'];
$varSobreNome = $_POST['Name2'];
$varNúmero = $_POST['Número'];
$varEmail = $_POST['Email'];
$varComentário = $_POST['Comentário'];
$varEmail = 'Results from Contact form';
$emailadd = 'marcos_lebelini@hotmail.com';

$req = '0';
}

{
$errorMessage = "";
if(empty($_POST['Name']))
{
$errorMessage .= "<li>Introduza o seu nome.</li>";
}

if(empty($_POST['Name2']))
{
$errorMessage .= "<li>Introduza o seu sobrenome.</li>";
}
if(empty($_POST['Número']))
{
$errorMessage .= "<li>Introduza o seu número.</li>";
}
if(empty($_POST['Email']))
{
$errorMessage .= "<li>Introduza o seu email.</li>";
}


$varNome = $_POST['Name'];
$varSobreNome = $_POST['Name2'];
$varNúmero = $_POST['Número'];
$varEmail = $_POST['Email'];

if(!empty($errorMessage))
{
echo("<p>Esqueceu-se de introduzir os seguintes tópicos.</p>\n");
echo("<ul>" . $errorMessage . "</ul>\n");
}
}

if($errorMessage != "")
{
echo("<p>There was an error:</p>\n");
echo("<ul>" . $errorMessage . "</ul>\n");
}
else
{
mail($emailadd, $varEmail, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
exit

?>


</body>
</html>

Corrosive
07-23-2012, 07:23 AM
Is mail function enabled on your server?

Marcos
07-24-2012, 07:55 PM
Is mail function enabled on your server?

I have no clue but problably not, and I'm still looking for a way xD.

edbr
07-25-2012, 02:25 AM
you need a technology capable of sending. if you dnt know if you have php on your server, then of course the php handler wont work. find out what you have most servers have php or asp but you could also use a perl script normally you would be given the path to that by your host

Marcos
07-26-2012, 08:07 PM
Hey i have been checking on on this websites:

Tutorial

--> http://www.tangledindesign.com/blog/how-to-create-a-contact-form-using-html5-css3-and-php/

SMTP4Dev

-->http://smtp4dev.codeplex.com/

I have been looking in the tutorial and i found that i need SMTP4Dev and SharePointServer, and I concluded that this isn't easy yet I don't know why I just want to continue to make this form xD, oh and I also found this script.



<?php
/*
From http://www.html-form-guide.com
This is the simplest emailer one can have in PHP.
If this does not work, then the PHP email configuration is bad!
*/
$msg="";
if(isset($_POST['submit']))
{
/* ****Important!****
replace name@your-web-site.com below
with an email address that belongs to
the website where the script is uploaded.
For example, if you are uploading this script to
www.my-web-site.com, then an email like
form@my-web-site.com is good.
*/

$from_add = "localhost@Contacte.com";

$to_add = "marcosbranco01@gmail.com"; //<-- put your yahoo/gmail email address here

$subject = "Test Subject";
$message = "Test Message";

$headers = "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";


if(mail($to_add,$subject,$message,$headers))
{
$msg = "Mail sent OK";
}
else
{
$msg = "Error sending email!";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test form to email</title>
</head>

<body>
<?php echo $msg ?>
<p>
<form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='post'>
<input type='submit' name='submit' value='Submit'>
</form>
</p>


</body>
</html>



Also from a guide, and NOW what I want to do is link my form (Contacte.php) to this script (samplemail.php) because when I click submit on my form, it goes to the samplemail.php file, due the <form action="samplemail.php">, and then it appears a submit button on that page.

I know this is kind of lazy but I need any help I can get! I have been searching, I can be searching even harder but I made this post in hope of someone to help me, and till now, you have ;D! I just need some more info!

Thank you for your help.!

(Still needing eheh)

Marcos
07-27-2012, 12:01 AM
Mhm... looks like I have found my answer, for now atleast xD, looks like I need SMTP, a server, what I had, (SMPT4DEV) was a test server, so to speak, now I'm trying to configure it, if I have any doubts I'll consult you!

Thanks!

Marcos
07-27-2012, 01:52 AM
So I managed to configure the SMPT using gmail as my server but now I'm facing a new problem and this one I can't really figure out lol, it's has to do with my script. I get this error



]: SMTP server response: 500 Syntax Error in C:\xampp\htdocs\xampp\website\Contacte2.php on line 19



And I don't know what it's wrong o.O, mind explaining me?



<?php

$msg="";

if(isset($_POST['Submit']))
{


$MESSAGE_BODY = "Nome: \r\n".$_POST["Name"]."";
$MESSAGE_BODY .= "Sobrenome: \r\n".$_POST["Name2"]."";
$MESSAGE_BODY .= " Numero: \r\n".$_POST["Número"]."";
$MESSAGE_BODY .= "Email: \r\n".$_POST["Email"]."";
$MESSAGE_BODY .= "Comentario: \r\n".nl2br($_POST["Comentário"])."";

$from_add = "marcosbranco01@gmail.com";

$headers = "From: $from_add \r\n";

if(mail($MESSAGE_BODY,$MESSAGE_BODY,$MESSAGE_BODY, $headers))
{
$msg = "Mail sent OK";
}
else
{
$msg = "Error sending email!";
}
}
?>

Corrosive
07-27-2012, 07:50 AM
Which line is 19? Not sure why $MESSAGE_BODY is fed into the form three times when the contents are concatenated. Surely that would mean it only needs to go in once? Bear in mind I'm no PHP expert!

edbr
07-27-2012, 07:53 AM
no you are correct corrosive

Corrosive
07-27-2012, 08:09 AM
So I managed to configure the SMPT using gmail as my server

An SMTP script is a complex thing and yours doesn't carry any log in details or anything like it. It is still trying to use the mail() function in PHP.

It is well worth contacting your hosting company and seeing if they have any pre-built form 2 mail scripts that are designed to work in their environment. Web hosts see the value of web forms and often have a script repository that you can configure and use whilst staying within the boundaries of what they allow.

Corrosive
07-27-2012, 08:10 AM
no you are correct corrosive

Thanks Ed, that makes me feel better :D