that is the warning i get from this code,
Warning: Invalid argument supplied for foreach() in /home/*****/public_html/test/contact1.php on line 77
i was just trying to make a contact form for my website and that error keeps appearing !
could anyone help me please thanks
Code:
<?php
if (empty($_POST) === false) {
$errors = array();
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
if (empty($name) === true || empty($email) === true || empty($message) === true) {
$errors = 'Name, Email and Message are required!';
} else {
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
$errors = 'That\'s not a valid email address';
}
if (ctype_alpha($name) === false) {
$errors = 'Name must only contain letters!';
}
}
if(empty($errors) === true) {
mail('*******@hotmail.co.uk', 'Contact Form', $message, 'From:' . $email);
header('Location: index.php?sent');
exit();
}
}
?>
<DOCTYPE html>
<body>
<?php
if(isset($_GET['sent']) === true) {
echo '<p>Thanks for contacting us!</p>';
} else {
if(empty($errors) === false) {
}echo '<ul>';
{
"line 77" foreach($errors as $error)
echo'<li>', $errors , '</li>';
}
echo'</ul>';
}
{
?>
<form method="post">
<p>
<label for="name">Name:</label><br/>
<input type="text" name="name" id="name" <?php if(isset($_POST['name']) === true) { echo 'value="', strip_tags($_POST['name']), '"';} ?>>
</p>
<p>
<label for="email">Email:</label><br/>
<input type="text" name="email" id="email" <?php if(isset($_POST['email']) === true) { echo 'value="', strip_tags($_POST['email']), '"';} ?>>
</p>
<p>
<label for="message">Message:</label><br/>
<textarea name="message" id="message"><?php if(isset($_POST['message']) === true) { echo strip_tags($_POST['message']);} ?></textarea>
</p>
<p>
<input type="submit" value="Submit" />
</p>
</form>
<?php
}
?>
</body>
i was just trying to make a contact form for my website and that error keeps appearing !
could anyone help me please thanks