Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

PHP Contact form help...

the mail() function

Moderators: macek, egami, gesf

PHP Contact form help...

Postby Brasil360 » Fri Apr 22, 2011 6:35 pm

I don know why a domain name appears after the name on the header of the email which I receive from my form?
I use this bit in my php code:
Code: Select all
// From
$header="from: $name";


and this domain appears on my email header after the "name":
Code: Select all
From:name@whl0010.whservidor.com


What is wrong?

Please help because this is causing many problems...
Brasil360
New php-forum User
New php-forum User
 
Posts: 12
Joined: Fri Apr 22, 2011 6:46 am
Location: BH, MG, Brazil

Re: PHP Contact form help...

Postby johnj » Sat Apr 23, 2011 12:15 am

You need to check how $name is getting populated.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP Contact form help...

Postby Brasil360 » Sat Apr 23, 2011 4:08 am

This is the PHP code:
Code: Select all
<?php
// place the posted data into variables
$EmailFrom = Trim(stripslashes($_POST['email']));
$name = Trim(stripslashes($_POST['fullname']));
$subject = "$name";
// prepare email body text
$Body = "";
$Body .= "From: $name";
$Body .= "\n";
$Body .= "Email: $EmailFrom";
$Body .= "\n";
// Enter your email address
$to ='someone@somewhere.com';
// From
$header="from: $EmailFrom";
// send email
$success = mail($to, $subject, $Body, $header);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>


and the HTML form:
Code: Select all
<form name="contact" action="test.php" method="post">
<table width="500" border="0" cellspacing="4" cellpadding="0">
<tr>
<td align="right"><div align="right">
<p class="CopyrightLine">nome completo:<span class="style1">*</span></p>
</div></td>
<td width="330" align="left"><input name="fullname" type="text" class="SelectingMenu" size="25" maxlength="30" /></td>
</tr>
<tr>
<td><div align="right">
<p class="CopyrightLine">email:<span class="style1">*</span></p>
</div></td>
<td><input name="email" type="text" class="SelectingMenu" size="25" maxlength="50"/></td>
</tr>
<tr valign="center">
<td><div align="right">
<p class="CopyrightLine">envie:&nbsp;&nbsp;&nbsp;</p>
</div></td>
<td><div align="left">
<input name="submit" type="submit" value="submit"/>
</div></td>
</tr>
</table>
</form>


In fact I receive email from this form if I don't fill the email field with an email address!
Brasil360
New php-forum User
New php-forum User
 
Posts: 12
Joined: Fri Apr 22, 2011 6:46 am
Location: BH, MG, Brazil

Re: PHP Contact form help...

Postby johnj » Sat Apr 23, 2011 7:28 am

In fact I receive email from this form if I don't fill the email field with an email address!...
In that case it is picking the value from php.ini.....can you please check if this is what is happening?
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP Contact form help...

Postby Brasil360 » Sat Apr 23, 2011 9:52 am

johnj wrote:In that case it is picking the value from php.ini.....can you please check if this is what is happening?

Well,.... obviously I am with a very basic knowledge of PHP just to mess with some codes and make it more personalized. The question is how can I find the answer to your question, and even where should I be looking for the php.ini?
Brasil360
New php-forum User
New php-forum User
 
Posts: 12
Joined: Fri Apr 22, 2011 6:46 am
Location: BH, MG, Brazil

Re: PHP Contact form help...

Postby johnj » Sat Apr 23, 2011 7:57 pm

You have coded $header="from: $EmailFrom"; So, obvioulsy $EmailFrom will have the domain name.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP Contact form help...

Postby johnj » Sat Apr 23, 2011 7:58 pm

I do not know where you have placed your php.ini file - by default it should be in your 'php' directory but it can also be placed somewhere else.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP Contact form help...

Postby Brasil360 » Sun Apr 24, 2011 2:58 am

Well thanks everyone here trying to help. I called my host company and they explained that all these are happening because I must be using SMTP authentication code and bunch of other things which now they provided me with. It looks everything works just fine and now I have to personalize my form around it.

A small part of it is this code blow:
Code: Select all
$usuario = 'usuario@seu-dominio';
/*senha da conta de email acima*/
$senha = 'senha-do-usuario';
Brasil360
New php-forum User
New php-forum User
 
Posts: 12
Joined: Fri Apr 22, 2011 6:46 am
Location: BH, MG, Brazil


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.