0

I'm trying to create a website and my PHP and html just wont work!! When I input data the website doesnt send the information to my email, and in the input forms, my validation is showing instead of the placeholder!!! please help!!!!:-)

my html is as follows:

<form class="form-horizontal" role="form" method="post" action="index.php">
       <div class="form-group">
    <label for="name" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="name" name="name" placeholder="Preferred Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
    </div>
</div>
<div class="form-group">
    <label for="email" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
        <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
    </div>
</div>
<div class="form-group">
    <label for="number" class="col-sm-2 control-label">Contact Number</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="number" name="number" placeholder="0000000000">
    </div>
</div>
<div class="form-group">
    <label for="message" class="col-sm-2 control-label">Message</label>
    <div class="col-sm-10">
        <textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
    </div>
</div>
<div class="form-group">
    <div class="col-sm-10 col-sm-offset-2">
        <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
    </div>
</div>
<div class="form-group">
    <div class="col-sm-10 col-sm-offset-2">
        <?php echo $result; ?>    
    </div>
</div>

my PHP is as follows:

$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
 $validationOK=true;
 if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
 exit;
 }

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
 if ($success){
  print "<meta http-equiv=\"refresh\`content=\"0;URL=contactthanks.php\">";
 }
 else{   
 print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
 }
 ?>
pnuts
  • 58,317
  • 11
  • 87
  • 139

1 Answers1

2

you have not closed the form tag and in contact there is no value given of post paste this code and check and while using html5 validation it will set validation error message using placeholder like please enter+your placeholder

  <form class="form-horizontal" role="form" method="post" action="index.php">
           <div class="form-group">
        <label for="name" class="col-sm-2 control-label">Name</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="name" name="name" placeholder="Preferred Name" value="<?php echo @htmlspecialchars($_POST['name']); ?>">
        </div>
    </div>
    <div class="form-group">
        <label for="email" class="col-sm-2 control-label">Email</label>
        <div class="col-sm-10">
            <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com" value="<?php echo @htmlspecialchars($_POST['email']); ?>">
        </div>
    </div>
    <div class="form-group">
        <label for="number" class="col-sm-2 control-label">Contact Number</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="number" name="number" placeholder="0000000000" value="<?php echo @$_POST['your_contact_filed_name'] ?>">
        </div>
    </div>
    <div class="form-group">
        <label for="message" class="col-sm-2 control-label">Message</label>
        <div class="col-sm-10">
            <textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars(@$_POST['message']);?></textarea>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-10 col-sm-offset-2">
            <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-10 col-sm-offset-2">
            <?php echo @$result; ?>    
        </div>
    </div>
    </form>
PRANAV
  • 629
  • 4
  • 13