I am getting an email from my contact form at the same time every night, but I dont think it is spam since the only thing in my email is:
Results from contact form:
And that is all that is in my email. Also if I submit the form without filling out any fields I will get the name of the field like “Name:” with no information following it so I dont think it is the result from users.
When I implement a spry validation to the input fields I still get the blank emails at the same time.
My site is still in the testing phase and I am wanting to launch it to its actually domain soon so any help would be nice.
Oh and I am obviously new to PHP.
PHP script that sends emails rip away, lol:
<?php
// Subject of email sent to you.
$subject = ‘Results from Contact Form’;
// Your email address. This is where the form information will be sent.
$emailadd = ‘myemail@yahoo.com’;
Thanks for the help. I am not sure if I fully understand what you are saying but I did plug in your above code so hopefully I can figure it out and get it to work.
I have never messed with php and I am trying to find someone I know to help me with this part but I am not having any luck so I appreciate the tips. I though this would be real easy and I could find a working code, but it has created a small inconvenience at the moment.
here is what I did:
<?php
// Subject of email sent to you.
$subject = 'Results from Index Form';
// Your email address. This is where the form information will be sent.
$emailadd = 'coryfaust21@yahoo.com';
// Where to redirect after form is processed.
$url = 'http://www.lubbockalamoremodeling.com';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$text = "Results from Index form:\
\
";
$space = ' ';
$line = '';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\
', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
thank you for posting more informations, sorry to confused you, i didn’t meant it that way. please try this one out,
this is your form
<form id="form2" action="test.php" method="post">
<h3><span>Free Estimate</span></h3>
<label for="text1">Full Name:</label>
<span id="sprytextfield1">
<input type="text" name="Name" id="text1" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<label>Phone Number:</label>
<span id="sprytextfield2">
<input type="text" name="Phone" id="text2" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<label>Email:</label>
<input name="email" type="text" size="30"/>
<label for="textarea1">Message:</label>
<span id="sprytextarea1">
<textarea name="Message" id="textarea1" cols="30" rows="4"></textarea>
<span class="textareaRequiredMsg">A value is required.</span><span class="textareaMinCharsMsg">Minimum number of characters not met.</span></span>
<input type="hidden" name="token" value="1" />
<input name="submit" type="submit" value="Submit" class="subbttn" />
</form>
this is your indexresults.php file
if($_POST['token']){
// Subject of email sent to you.
$subject = 'Results from Index Form';
// Your email address. This is where the form information will be sent.
$emailadd = 'YOUR_EMAIL@yahoo.com';
// Where to redirect after form is processed.
$url = 'http://www.lubbockalamoremodeling.com';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$text = "Results from Index form:\
\
";
$space = ' ';
$line = '';
print_r($_POST);
echo '<br />';
foreach ($_POST as $key => $value){
if ($value == ''){
echo "$key is empty";
die;
}
$j = strlen($key);
if ($j >= 20){
echo "Name of form element $key cannot be longer than 20 characters";
die;
}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++){
$space .= ' ';
}
$value = str_replace('\
', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
exit();
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
The problem there is your indexresults.php file doesn’t make any initial checking before proceeding with the whole script processing so it sends out a blank email every time it is accessed. I just added a “token” as a sign that it was triggered from your html form.
I don’t know where do you intend to flag $req to proceed with the email sending but upon reading all available information’s on this topic, this should prevent it from sending you blank email.
Rajub: I have never used php until now so I found the php script in a tutorial so I am not sure why it has the met refresh or what it even does?
I plan on adding anti spamming when I am completely done with the site and its ready to be launched, but at the moment I am occupied with other aspects of the site unless you believe it will fix the problem, but I am thinking it is something with my code since the emails are blank.
thanks for the reply too.
<form id="form2" action="indexresults.php" method="post">
<h3><span>Free Estimate</span></h3>
<label for="text1">Full Name:</label>
<span id="sprytextfield1">
<input type="text" name="Name" id="text1" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<label>Phone Number:</label>
<span id="sprytextfield2">
<input type="text" name="Phone" id="text2" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<label>Email:</label>
<input name="email" type="text" size="30"/>
<label for="textarea1">Message:</label>
<span id="sprytextarea1">
<textarea name="Message" id="textarea1" cols="30" rows="4"></textarea>
<span class="textareaRequiredMsg">A value is required.</span><span class="textareaMinCharsMsg">Minimum number of characters not met.</span></span>
<input name="submit" type="submit" value="Submit" class="subbttn" />
</form>
When I fire the submit action the form will not process since the required fields are blank and when I make it have no required fields and fire the submit action the emails still show the label names with empty information next them.