this is the PHP email script that I want to use for my website. I am creating this website for my father's company, and decided to make it with Bootstrap. The HTML and CSS knowledge required was something I could still do, but this is beyond my knowledge. Somewhere on the Internet I dug up this script and it doesn't work for me. I am sure that there probably is a very logical reason for this, but I have no knowledge whatsoever of PHP-scripting... I was hoping you could help this newbie out. I am very much willing to learn, but to study PHP just for a simple script(I am not planning to do more web "development") seems a bit overexaggerating. Anyway, I am rambling on too much. Here is the script I found(I've called it: sendemail.php):
<?php
'success',
'message'=>'Thank you for contacting us. As soon as possible we shall be in touch with you '
);
$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'EMAIL_ADRESS_HERE';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
?>
Of course, I replaced the value from "email_to" with my email adress of choice, I tested even multiple email adresses and it simply doesn't work. I get the spinning icon with the "processing" text as defined in my main.js file, but that's it. It stays at that forever. I feel like this is also necessary to understand why the PHP-script isn't working(perhaps I'm wrong), but here is the relevant HTML code in the Bootstrap form:
<section id="contact-page">
<div class="container">
<div class="center">
<h2>Be in touch with us:</h2>
<p class="lead">DUMMY TEXT</p>
</div>
<div class="row contact-wrap">
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>E-mail *</label>
<input type="email" name="email" class="form-control" required="required">
</div>
<div class="form-group">
<label>Phone</label>
<input type="number" class="form-control">
</div>
<div class="form-group">
<label>Company Name</label>
<input type="text" class="form-control">
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
</div>
</section>
If you require more information or anything, please tell and I will provide it immediately, because I am dying to get this to work.
Two things I want to highlight:
- The form was made with preset Bootstrap tags, and all of it Bootstrap. Maybe this affects the way the script works?
- I am working on this locally on my PC, so it isn't run from a server or anything. I still need to take it out for a test spin. I don't know if this affects the way the email is forwarded... Yeah, I am really a complete noob.
All help and tips are much appreciated and thank you in advance!