herghost Posted August 2, 2008 Share Posted August 2, 2008 I have been working on a 'simple' 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 More sharing options...
genericnumber1 Posted August 2, 2008 Share Posted August 2, 2008 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 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. Link to comment https://forums.phpfreaks.com/topic/117860-solved-form-array-problem/#findComment-606232 Share on other sites More sharing options...
Barand Posted August 2, 2008 Share Posted August 2, 2008 you could try this, which will join the array elements into a comma-separated string $main = $name . " " . $message . " " . join (', ', $checkbox); Link to comment https://forums.phpfreaks.com/topic/117860-solved-form-array-problem/#findComment-606257 Share on other sites More sharing options...
herghost Posted August 3, 2008 Author Share Posted August 3, 2008 you could try this, which will join the array elements into a comma-separated string $main = $name . " " . $message . " " . join (', ', $checkbox); Thanks, that works perfectly Link to comment https://forums.phpfreaks.com/topic/117860-solved-form-array-problem/#findComment-606657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.