Jump to content

[SOLVED] Form Array Problem


herghost

Recommended Posts

I have been working on a 'simple' :P contact form for other 4 hours now and I am about to smash the screen!

 

I have this code

 

<html>
<body>
<?php


$to = "*******@gmail.com";
$subject = "Contact Form";
$name = $HTTP_POST_VARS['name'];
$emailadd =$HTTP_POST_VARS['emailadd'];
$message = $HTTP_POST_VARS['message'];
$checkbox=$_POST['checkbox'];
$main = $name . " " . $message . " " . $checkbox;






if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $emailadd)) 
{
  echo "<h4>Invalid email address</h4>";
  echo "<a href='javascript:history.back(1);'>back</a>";
} 
elseif ($name == "") 
{
  	echo "<h4>Please enter your name</h4>";
  	echo "<a href='javascript:history.back(1);'>back</a>";
  	}
  		elseif ($message == "") 
	{
	echo "<h4>Please enter a message</h4>";
 	echo "<a href='javascript:history.back(1);'>back</a>";
  		}
  
  
		elseif (mail($to,$subject,$emailadd,$main)) 
		{
  			echo "<h4>Thank you for sending us a message, we shall get back to you shortly<br><br>www.tiny-pixel.co.uk</h4>";
		} 
			else 
			{
  				echo "<h4>Can't send email to $email</h4>";
			}




  
?>

</body>
</html>

 

Which all works and sends to my email address fine, apart from the result of the checkbox in the email literally prints the word 'array' instead of the output of the box.

 

I literally am at the end of my teather with this, if a really nice person would like to make the changes so it shows the result and explain to me what the code means I will be forever thankful!

 

 

Link to comment
https://forums.phpfreaks.com/topic/117860-solved-form-array-problem/
Share on other sites

print_r() or var_dump() the contents of the array and post the content here. It will help us change the code to the form you want :P

 

The reason it's displaying as "array" is because... well... you're echoing an array, and since it's not an echoable variable type it's just telling you that it's an array and it doesn't know what element to display.

Archived

This topic is now archived and is closed to further replies.

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