Jump to content

Need Some Help New to PHP


n7dz

Recommended Posts

hey guys i dont know how to code php so i was hoping somone could help me create a php file here is the form that im creating:

* * Edit * * i went with a new form a link posted down below. ignore this codeand my request for a php file * *

<section id="contact" class="content-section form contact light space">
<div class="container">
<div class="content cover text-center">
<div class="heading">
<h2>Getting in touch</h2>
<p>Do you have questions or wanna leave feedback?<br/><br/></p>
</div>
<div class="row">
<span id="message"></span><!-- remove #message to stop floating jQuery messages -->
<form target="#" name="contact">
<div class="col-lg-5 anim fadeInLeft animated" style="visibility: visible;">
<span class="input-group">
<i class="fa fa-user"></i>
<input type="text" name="contactName" id="contactName" class="lg" placeholder="Name">
</span><!-- .input-group -->
<span class="input-group">
<i class="fa fa-envelope"></i>
<input type="text" name="contactEmail" id="contactAddress" class="lg" placeholder="Email Address">
</span><!-- .input-group -->
<span class="input-group">
<i class="fa fa-book"></i>
<input type="text" name="contactSubject" id="contactSubject" class="lg" placeholder="Subject">
</span><!-- .input-group -->
</div><!-- .col-5 -->
<div class="col-lg-7 anim fadeInRight animated" style="visibility: visible;">
<span class="input-group">
<textarea name="contactMessage" id="contactMessage" class="lg" placeholder="What's on your mind?"></textarea>
</span><!-- .input-group -->
<span class="input-group">
<button class="submit" id="submit_contact" data-loading-text="SENDING...">SEND</button>
</span><!-- .input-group -->
</div>
</form>
</div>
</div><!-- .container -->
<span id="message_sent"><i class="fa-check fa"></i></span><!-- jQuery display of giant checkmark -->
</section>
Edited by n7dz
Link to comment
Share on other sites

If you need PHP then now's a good time to learn it. I'm here to help people learn, not write code for them. The W3Schools PHP tutorial even has a section about sending e-mail with PHP.

Link to comment
Share on other sites

Yh, like seriously, if only you need to process this why don't you learn it. But if you need help drop me a PM. I wish to help you though.

Link to comment
Share on other sites

<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "Thank You and Dont forget to Stop By";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'xdz69x@gmail.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.nn"."Here are the details:nnName: $namennEmail: $email_addressnnPhone: $phonennMessage:n$message";
$headers = "From: noreply@yahoo.comn"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
Link to comment
Share on other sites

First, look in your HTML for something like <input type="..." name="...">. Next step is to change the name form something meaningful. E.g: for the email field use <input type="text" name="email">, for the message use name="message" and so on.

At last go to the PHP code and use the exacly same name between the square brackets in $_POST[' ']

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...