Page 1 of 1

contact form not working...

Posted: Tue Jul 03, 2007 3:00 am
by truepal20032001
no matter if i insert everything correcty, it will still give me the negative result, what's wrong?...

Code: Select all

<div align="center">
  <h1><strong></p>
</div>
<div align="center">
  <div align="center">
  <div align="center">
<meta http-equiv="refresh" content="2;url=/home.html">
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$msg = "Name: $_POST[name]\n";
$msg.= "Email: $_POST[email]\n";
$msg.= "Phone: $_POST[phone]\n";
$msg.= "Comment/Message:\n";
$msg.= "$_POST[comment]\n<br><br>";
$msg.= "Message recieved: ".date('H:i, jS F');


If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > ){
@mail('my@mail.com','Comment/Message',$msg,'FROM:'.$_POST[email]);
echo "Thankyou! You'll be replied soon.</strong></h1>
  <p><strong><br />
  </strong><br />
  <strong></strong></p>
  <p>";
echo '<html><h1 align="center"><img src="info/check.jpg"</html>';
}
else{
echo "ERROR!!</strong></h1>
  <p><strong>An error has just occured, these might have been the cause: <br />
  1. Did not fill in all of the neccessary blanks.</strong><br />
  <strong>2.Invalid Information<br>3.Comment is less that 8 characters long.</strong></p>
  <p>";
echo '<html><h1 align="center"><img src="info/error.jpg" width="433" height="133"/></html>';
}
?>
every input result:

Code: Select all

ERROR!!
   An error has just occured, these might have been the cause:
  
  1. Did not fill in all of the neccessary blanks.
  2.Invalid Information<br>3.Comment is less that 8 characters long.

Posted: Tue Jul 03, 2007 3:10 am
by Rovas
You had to use

Code: Select all

<?php
if (!isset ($_POST[name]) && !isset($_POST['email']))
{
   $name = $_POST['name'];
   $email = $_POST['email'];
//the rest
}
else
{
   If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > ){// your code} 
}
?>
Now it should work.

Posted: Tue Jul 03, 2007 3:22 am
by truepal20032001
it still does not work...
i believe the problem is

Code: Select all

If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > )
, but don't know what's wrong,

Posted: Tue Jul 03, 2007 3:26 am
by Gente
Please post the values of your variables.

Posted: Tue Jul 03, 2007 3:30 am
by truepal20032001

Code: Select all

$name = 'Joe';
$email = 'Joe@hoody.com';
$comment = 'This is a simple comment';

Posted: Tue Jul 03, 2007 3:53 am
by Gente

Code: Select all

<?php
	$name = 'Joe';
	$email = 'Joe@hoody.com';
	$comment = 'This is a simple comment';
	if ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > )
	{
		echo 'Yahoo';
	}
	else
	{
		echo 'Oh...';
	}
?>
Works perfect. Are you sure you have these values right before your if statement if your script?

Posted: Tue Jul 03, 2007 12:23 pm
by RobertGonzalez
Echo the values you are comparing just before the conditional so you can see what PHP is seeing.

Posted: Tue Jul 03, 2007 2:35 pm
by truepal20032001
well you see that is what i am assuming because that is what i put in the contact form and then it is converted to this:

Code: Select all

$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment']; 


$name = 'joe';
$email = 'email@somewhere.com';
$comment = 'comment here';

Posted: Tue Jul 03, 2007 3:01 pm
by Gente
It will take less then a minute to verify... Just do it.

Code: Select all

echo "Debug start<br/>";
echo $name.' '.$email.' '.$comment.'<br/>';
echo "Debug finish<br/>";
if ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > )
// The rest of your code

Posted: Tue Jul 03, 2007 3:01 pm
by RobertGonzalez
truepal20032001 wrote:well you see that is what i am assuming ...
I didn't ask you to assume, I asked you to...
Everah wrote:Echo the values you are comparing just before the conditional so you can see what PHP is seeing.
That is the only way to see what PHP is seeing. Please do that and report back.

Posted: Tue Jul 03, 2007 3:42 pm
by truepal20032001

Code: Select all

Debug start

Debug finish
and that is weird, cause i checked the for and everything checks out..., here is html form:

Code: Select all

<td width="84%" rowspan="5" align="left" valign="top"><form name="form1" method="post" action="contact.php">
                        <span class="style20"><span class="style21">
                        <input name="name" type="text" id="name">
                        <input name="email" type="text" id="email">
                        <input name="phone" type="text" id="phone">
</span></span>
                        <span class="style20"><span class="style21">
                        <textarea name="comment" cols="45" rows="6" wrap="on" id="comment"></textarea>
                        <input type="submit" name="Submit" value="Submit">
</span></span>
                      </form>
and ofcource the action:contact.php

Code: Select all

<div align="center">
  <h1><strong></p>
</div>
<div align="center">
  <div align="center">
  <div align="center">

<?php
function error(){
echo "ERROR!!</strong></h1>
  <p><strong>An error has just occured, these might have been the cause: <br />
  1. Did not fill in all of the neccessary blanks.</strong><br />
  <strong>2.Invalid Information<br>3.Comment is less that 8 characters 

long.</strong></p>
  <p>";
echo '<html><h1 align="center"><img src="info/error.jpg" width="433" 

height="133"/></html>';
}
if (!isset ($_POST[name]) && !isset($_POST['email']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$msg = "Name: $_POST[name]\n";
$msg.= "Email: $_POST[email]\n";
$msg.= "Phone: $_POST[phone]\n";
$msg.= "Comment/Message:\n";
$msg.= "$_POST[comment]\n<br><br>";
$msg.= "Message recieved: ".date('H:i, jS F');
}
echo "Debug start<br/>";
echo "$name". "$email". "$comment"."<br/>";
echo "Debug finish<br/>"; 

If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen

($comment) > ){
@mail('truepal20032001@yahoo.com','Comment/Message',$msg,'FROM:'.$_POST

[email]);
echo "Thankyou! You'll be replied soon.</strong></h1>
  <p><strong><br />
  </strong><br />
  <strong></strong></p>
  <p>";
echo '<html><h1 align="center"><img src="info/check.jpg"</html>';
}
else{
error();
}
?>
i am sorry if iam tiring you with this code

Posted: Tue Jul 03, 2007 3:53 pm
by Gente
Are you joking???
Look at your code! Here:

Code: Select all

if (!isset ($_POST[name]) && !isset($_POST['email']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
// Yo will never reach this part!!! Because of YOUR CONDITION
}
Your initial post was without this statement :evil:

Posted: Tue Jul 03, 2007 4:01 pm
by truepal20032001
Rovas wrote:You had to use

Code: Select all

<?php
if (!isset ($_POST['name']) && !isset($_POST['email']))
{
   $name = $_POST['name'];
   $email = $_POST['email'];
//the rest
}
else
{
   If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > ){// your code} 
}
?>
Now it should work.
but that is what they told me to put, if before that it still didn't work that is why i said that this might be the problem,

Code: Select all

If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > 8))
it will still not work if i fix it like this:
Rovas wrote:You had to use

Code: Select all

<?php
if (!isset ($_POST['name']) && !isset($_POST['email']))
{
error();
}
else
{ $name = $_POST['name'];
$comment = $_POST['comment'];
$email = $_POST['email'];


   If ((strlen($name) > 1) && (strlen($email) > 1) && (strstr($email,'@')) && (strlen($comment) > ){// your code} 
}
?>
Now it should work.

Posted: Tue Jul 03, 2007 4:23 pm
by RobertGonzalez

Code: Select all

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment']; 
?>
If there is no post array then these will all be null (which is another way of saying empty, not set, null).

You also need to check if they are set.

Code: Select all

<?php
if ($_SERVER['REQUEST_METHOD'] == 'post' && !empty($_POST))
{
  // You now have a post array that is not empty.

  // Set some vars and handle your business
}
else
{
  // There was no post.

  // Do what you do when there is no form posted.
}
?>