jacob_1988
-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by jacob_1988
-
-
What can I do regarding the code (as below?) I keep getting the message 'undefined index: robots' on line 3. Moreover, I wanted the code to guard my site against spammers.
if($_POST['robots'] != '') {
echo 'No spammers here!';
} else {
// Process the the form
} -
I changed the 'Message' wording to the correct case-sensitive word 'message' - this made the program print a message. I'm still getting undefined variable with 'email' and 'from' line 18.
Line 18: $email, $subject, $message, "from:".$from);
-
I actually got the file to send a small email but it contains no message? I'm now having to sort the 'undefined index: robot', 'undefined index: Message' and the undefined variables headers, email and from.
The full line of the index.php is the web address plus the php file (as below.)
<form class="form-horizontal" role="form" action="https://xxxxxx.000webhostapp.com/home/xxxxxx/index.php" method="POST">
-
I have a designed a small webpage which also has a 'contact me' selection but I cannot seem to send/receive any message from my webpage? Moreover, how do I insert the correct code to make my php (contact page) file run correctly?
HTML Form Code:
<form class="form-horizontal" role="form" action="index.php" method="POST">
<div class="form-group row">
<label for="name" class="col-2 col-form-label">Name</label>
<div class="col-8">
<input type="text" class="form-control" type="text" id="name" name="name" placeholder="First and Last Name" value="">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-2 col-form-label">eMail</label>
<div class="col-8">
<input type="email" class="form-control" type="text" id="email" name="email" placeholder="example@domain.com" value="">
</div>
</div>
<div class="form-group row">
<label for="message" class="col-2 col-form-label">Message</label>
<div class="col-8">
<textarea class="form-control" row="4" name="message"></textarea>
</div>
</div>
<div class="form-group row">
<label for="human" class="col-2 col-form-label">2 + 3 = ?</label>
<div class="col-8">
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
</div>
</div>
<div class="form-group row">
<div class="col-6 offset-sm-2">
<input id="submit" name="submit" type="submit" value="Send Message!" class="btn-message btn-lg">
</div>
</div>
</form>PHP FORM Code:
<?php
if($_POST['robots'] != '') {
echo 'No spammers here!';
} else {
// Process the the form
}$to = 'xxxx.com';
$subject = 'info help ';
$message = 'From: ' . $_POST['name'] . "\n";
$message .= 'Email from: ' . $_POST['email'] . "\n";
$message .= "Message:\n" . $_POST['Message'] . "\n\n";
$headers .= 'Cc: admin@xxxxx.com';
mail($to, $subject, $message, $headers);
mail ($email, $subject, $message, "from:".$from);header('Location: index.html');
exit();?>
Insert contact Page PHP file in html.
in HTML/XHTML
Posted
But how do I correct it?