Sending confirmation email to user from form Laravel - php

I have a very simple front end form that I am successfully sending to myself, but I can't work out how to send a copy to the users supplied email address.
Am I right in thinking I need to add an array to the controller to make the user email an object for me to be able to send this to them?
My HMTL Form:
<div class="tab-content">
<div class="tab-pane" id="about">
<div class="row">
<h4 class="info-text"> Tell us about yourself and the project you are working on.</h4>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label><b>Contact Name</b> <small></small></label>
<input name="name" type="text" class="form-control" placeholder="Contact Name..." id="name" required>
</div>
<div class="form-group">
<label><b>Company</b><small></small></label>
<input name="company" type="text" class="form-control" placeholder="Company Name..." id="company" required>
</div>
<div class="form-group">
<label><b>Contact Number</b> <small></small></label>
<input name="phone" type="number" class="form-control" minlength="10" maxlength="15" placeholder="Number..." id="number" required>
</div>
</div>
<div class="col-sm-5 ">
<div class="form-group">
<label for="project"><b>Please tell us a little about the project you are working on</b> <small></small></label>
<textarea class="form-control" minlength="15" maxlength="255" name="project" rows="9" id="project" placeholder="Please enter project and building name..." required></textarea>
</div>
</div>
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label><b>Email </b><small></small></label>
<input name="email" type="email" class="form-control" placeholder="email#email.com" id="email" required>
</div>
</div>
</div>
</div>
the code that sends the email in the controller:
Mail::to('builder.enquiries#gmail.com')->send(new NewContactRequest($all_arrray));
Any help anyone could give would be great.
Thanks

Yes,
you can add a cc to your mail function.
Mail::to('builder.enquiries#gmail.com')
->cc(['abc#exabc.com','def#exabc.com'])
->send(new NewContactRequest($all_arrray));
Hope this helps you.

Related

Form is not getting submitted, even if method, action, and button type submit is given

Here is my Code i've given everything form method, form action and button type still form is not going to next page. Please help me with it. And thanks in advance!
<div class="contact-form-wrap">
<form id="contactForm" novalidate="true" action="sendmail.php" method="POST">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" required="" data-error="Please enter your name" placeholder="Enter your name">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input type="email" name="email" id="email" class="form-control" required="" data-error="Please enter your email" placeholder="Enter your email">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input type="number" name="number" id="number" class="form-control" required="" data-error="Please enter your phone number" placeholder="Enter Your Phone Number">
<div class="help-block with-errors"></div>
</div>
<button type="submit" class="default-btn" style="pointer-events: all; cursor: pointer;">Book Appointment</button>
<div id="msgSubmit" class="h3 text-center hidden"></div>
<div class="clearfix"></div>
</form>
</div>
try action="sendmail.php" (no slash)

Wordpress: PHP script cannot be find HTTP 404 ERROR

My current mission is to create a complete theme on WordPress. And to this is, a login system. Now, i've created the form and everything looks just fine, the problem is that wordpress is brawling with me and cannot locate my signup script, it creates a HTTP 404 error. Now I think that this has something to do with wordpress permalink system because it wants to find a page, instead of my signup.inc.php script.
Now this frustrates me because im kind of new to coding and I have no idea how to fix it!
Here is my code linking to the actual file located in a folder called 'includes'
<form action='includes/signup.inc.php' method="post">
<div class="form-group">
<label for="Username">Username</label>
<input type="text" class="form-control" name="uid" id="uid" placeholder="Username" required>
<small id="userhelp" class="form-text text-muted">This name will show on forums and the socialpage.</small>
</div>
<div class="form-group">
<label for="firstname">Firstname</label>
<input type="text" class="form-control" name="firstname" id="firstn" placeholder="Firstname" required>
</div>
<div class="form-group">
<label for="lastname">Lastname</label>
<input type="text" class="form-control" name="lastname" id="lastn" placeholder="Lastname" required>
</div>
<div class="form-group">
<label for="email">Email Adress</label>
<input type="email" class="form-control" name="mail" id="inputemail" aria-describedby="emailHelp" placeholder="Email" required>
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="pwd" id="password" placeholder="Password" required>
</div>
<div class="form-group ">
<label for="password">Repeat password</label>
<input type="password" class="form-control" name="pwd-repeat" id="password" placeholder=" Repeat password" required>
<small id="passHelp" class="form-text text-muted">Please retype your password.</small>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="invalidCheck3" required>
<label class="form-check-label" for="invalidCheck3">Agree to terms and conditions</label>
<div class="invalid-feedback">
You must agree before submitting.
</div>
</div>
</div>
<button class="btn btn-dark" name="signup-submit" type="submit">Signup</button>
</form>
Please use this action in form:
<form action='<?php echo get_template_directory_uri(); ?>/includes/signup.inc.php' method="post">

Form in html not getting redirected to PHP file

I am creating a simple HTML website using bootstrap and CSS and am using PHP for form handling. I am using the POST method to submit the values of the form to a PHP file where I am trying to receive the values and printing them. However, when I press the submit button on the form, the HTML page is not getting redirected to the PHP file that is in the action element of the form. It just gets stuck on the HTML page. Please take a look at the below code and help me figure out why the values of the form are not getting submitted into the PHP file.
This is the code for the form in the HTML file:
<div class="container">
<div class="row">
<div class="contact-form">
<form action="contact.php" method="post" id="contact-form" role="form">
<fieldset>
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="fullname" class="form-control" id="full-name" placeholder="Full Name*" data-error="Full name is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" id="email" placeholder="Email Address*" data-error="Email is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="phone" class="form-control" placeholder="Phone number" id="phone" data-error="Phone number is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject*" name="subject" id="subject" data-error="Subject is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<textarea cols="40" rows="10" name="message" class="textarea form-control" placeholder="Your Message" id="message" data-error="Message is required" required></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<button class="btn-send" type="submit" name="submit">Send</button>
</div>
</div>
<div class="col-sm-12">
<div class='form-response'></div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
The contact.php file looks something like this:
<?php
if ( isset( $_POST['submit'] ) ) {
$fullName = $_POST['fullname'];
$email = $_POST['email'];
echo 'Your name is ' . $fullName .' and your email ID is' . $email;
}
?>
I have been unable to figure out exactly what the problem is. Please take look at this code and help me figure this problem out. Thanks in advance.
It should work. Have you made sure that the contact.php file is in the same folder as this html page?
put php code in same file.
use this html
<div class="container">
<div class="row">
<div class="contact-form">
<form action="" method="post">
<fieldset>
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="fullname" class="form-control" id="full-name" placeholder="Full Name*" data-error="Full name is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" id="email" placeholder="Email Address*" data-error="Email is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="phone" class="form-control" placeholder="Phone number" id="phone" data-error="Phone number is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject*" name="subject" id="subject" data-error="Subject is required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<textarea cols="40" rows="10" name="message" class="textarea form-control" placeholder="Your Message" id="message" data-error="Message is required" required></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<button class="btn-send" type="submit" name="submit">Send</button>
</div>
</div>
<div class="col-sm-12">
<div class='form-response'></div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
Your code is perfectly working. Make sure your folders are in right place
(eg : in wamp your folders must be inside www folder). And make sure your server is running.

PHP not receiving data from HTML5 form

I am recently getting into php and am running it locally on Xampp. I have created the following simple form followed by a few lines of php. It seems that no data is being passed through from the html form to the php page.
<form method="post" action="emailform.php" enctype="text/plain" class="form-horizontal">
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-10">
<div class="form-group">
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
</div>
</div>
</div>
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="full name">
</div>
<div class="form-group">
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-5 textarea">
<textarea class="form-control" name="message" id="message" rows="4" placeholder="message"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<button type="submit" class="btn" id="submit">Send</button>
</div>
</div>
</form>
This is the simple php code I am using to test:
<?php
$subject = 'No subject was set';
if (isset($_POST['subject'])) {
$subject = ($_POST['subject']);
}
echo "This is the subject:$subject";
?>
I appreciate any help as I have been struggling with this simple code for the past week now.
Two subject names!
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
^
and
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
^
Also remove enctype="text/plain" from the form
It's because PHP doesn't handle it

Submit Modal and run PHP script

I have the following Bootstrap Modal, which I am just submitting and eventually it will send an email. For right now I am just trying to echo Signing Up.
<div class="modal-body">
<form class="form-horizontal" name="commentform" method="post" action="signup.php">
<div class="form-group">
<label class="control-label col-md-4" for="first_name">First Name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="last_name">Last Name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="email">Email Address</label>
<div class="col-md-6 input-group">
<span class="input-group-addon">#</span>
<input type="email" class="form-control" id="email" name="email" placeholder="Email Address"/>
</div>
</div>
</form>
</div>
Here Is my signup.php code:
<?php
echo "Signing Up";
?>
However, when I run this on my dreamhost server and press the Sign Up button, nothing happens at all. My console provides me with this error: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Your code works fine for me as is (after adding a Submit button). See demo
Check your permissions on your files, make sure php files are 644 (-rw-r--r--)

Categories