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--)
Related
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.
For my website, when this particular page is clicked I want the form to be populated with data from the database. Here is the code for the form:
<form class="form-horizontal" role="form" method="post" action="{{url('/company-profile/update')}}">
{{ csrf_field() }}
#foreach($getAllDetails as $list)
<div class="form-group">
<div class="col-sm-10">
<label for="companyname" class="control-label">Company Name</label>
<input type="text" class="form-control" id="companyname" name="companyname" placeholder="Enter Company Name" value={{$list->companyName}}>
</div>
</div>
<div class="form-group">
<div class="col-xs-5 col-sm-4 col-md-3">
<label for="shortCode" class="control-label">Short Code</label>
<input class="form-control" id="shortCode" name="shortCode" placeholder="Short Code" value={{$list->shortCode}}>
</div>
<div class="col-xs-7 col-sm-6 col-md-7">
<label for="telnum" class="control-label">Telephone Number</label>
<input type="tel" class="form-control" id="telnum" name="telnum" placeholder="Tel. number" value={{$list->phoneNo}}>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label for="emailid" class="control-label">Email</label>
<input type="email" class="form-control" id="emailid" name="emailid" placeholder="Email" value={{$list->emailAddress}}>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label for="logoPath" class="control-label">Logo Path</label>
<input type="" class="form-control" id="logoPath" name="logoPath" placeholder="Enter Logo Path" value={{$list->logoPath}}>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label for="feedback" class="control-label">Contact Address</label>
<textarea class="form-control" id="address" name="address" rows="2" value={{$list->contactAddress}}></textarea>
</div>
</div>
#endforeach
<div class="form-group">
<div class="col-sm-10">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
This issue is:
For example, if I want to fetch the company name {{$list->companyName}} only the first word gets displayed. For example, If the company's name is National Film Institute, only National gets displayed.
Here is code the for my index function in the controller:
public function index()
{
$data['getAllDetails']= DB::table('tblcompany')->get();
return view('companyProfile.companyProfile', $data);
}
Change
value={{$list->your_field}}
to
value="{{$list->your_field}}"
I have a form which a user will complete with required fields. When all the required fields are completed, the submit button can be clicked to send the data.
I have been looking into googles reCAPTCHA, which seems to be working. However, is there a way I can put this as a required field? Currently, when the form is completed, the user can submit the form without verifying them self with the reCAPTCHA. Where as I would like the button to only become available once the required fields are completed.
Code Added as requested. Don't think it will be useful but this is all I have so far (as I have been trying figure out a way how to do this)
<form role="form" method="post" id="get_started_form" action="<?php echo base_url('auth/get_started')?>" data-toggle="validator" enctype="multipart/form-data">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
<div class="form-group has-feedback">
<label>First Name</label>
<input name="first_name" type="text" class="form-control" required pattern="^[a-zA-Z\-.,\s]+$" data-error="Please use text or symbols (- . ,) only." placeholder="First Name" id="first_name" maxlength="50" tabindex="1">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
<div class="form-group has-feedback">
<label>Last Name</label>
<input name="last_name" type="text" class="form-control" required pattern="^[a-zA-Z\-.,\s]+$" data-error="Please use text or symbols (- . ,) only." placeholder="Last Name" id="last_name" maxlength="50" tabindex="2">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="form-group has-feedback">
<label>Email</label>
<input name="email" type="email" class="form-control" required placeholder="Text#Text.Domain" id="email" maxlength="100" tabindex="3">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="g-recaptcha" data-sitekey="KEY_HERE"></div>
<button type="submit" value="Submit" id="get_staretd_form_button" class="btn btn-primary">Get Started</button>
</div>
</div>
</form>
You can try this ReCAPTCHA
.....................
In Codeigniter I am trying to call a function from form action and I get the following error:
requested URL /chat//layercake/form_validation was not found on this server.
<form class="form-horizontal" id="contact" data-toggle="validator" enctype="multipart/form-data" role="form" method="post" action="<?php echo base_url().'/layercake/form_validation'; ?>">
<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="First & Last Name" value="" required>
<div class="help-block with-errors"></div>
</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="" required>
<div class="help-block with-errors"></div>
</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" id="message" rows="4" name="message" required></textarea>
<div class="help-block with-errors"></div>
</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 alert">
</div>
</div>
</form>
Please help.
Change your action url base_url().'/layercake/form_validation'; to base_url().'layercake/form_validation';
Please look at your error. There are two // after chat.
Your action URL is wrong. Change action="<?php echo base_url().'/layercake/form_validation'; ?>" this as following in form tag
action="<?php echo site_url('layercake/form_validation'); ?>"
This question already has answers here:
Apache is downloading php files instead of displaying them
(27 answers)
Closed 7 years ago.
I am trying to save form data to mysql database for last 2 days, however, the form data doesn't gets saved to mysql database, instead it downloads the User Info.php code file to my computer every time I press submit button. Need assistance!
This is html form;
<form class="form-horizontal" role="form" action="User Info.php" method="post"/>
<div class="form-group">
<label class="control-label col-sm-2" for="First Name">First Name:</label>
<div class="col-sm-10">
<input type="text" name="FirstName" class="form-control" id="First Name" placeholder="First Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Last Name">Last Name:</label>
<div class="col-sm-10">
<input type="Last Name" name="LastName" class="form-control" id="Last Name" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Company Name">Company Name:</label>
<div class="col-sm-10">
<input type="Company Name" name="CompanyName" class="form-control" id="Company Name" placeholder="Company Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="Email" name="Email" class="form-control" id="Email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Message">Message</label>
<div class="col-sm-10">
<textarea type="Message" name="Message" class="form-control" rows="3" columns="50" id="Message" placeholder="Message"></textarea></div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button name="submit" class="submit-btn" type="submit">Submit</button>
This is php code db.php;
<?php
$conn = mysql_connect('localhost','root','....', 'testforlivesite') or die("error while connecting to the database");
$db = mysql_select_db('testforlivesite', $conn) or die("error while connecting to the database");
?>
User Info.php
<?php
include_once('db.php');
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$CompanyName = $_POST['CompanyName'];
$Email = $_POST['Email'];
$Message = $_POST['Message'];
if(mysql_query("INSERT INTO ContactUs (FirstName, LastName, CompanyName, Email, Message) VALUES ('$FirstName', '$LastName', '$CompanyName', '$Email', '$Message')"))
echo "Thanks for contacting!";
else
echo "Please rewrite the message.";
?>
change your file name from User Info.php to UserInfo.php remove the space and also rename your file from User Info.php to UserInfo.php.
<form class="form-horizontal" role="form" action="UserInfo.php" method="post"/>
<div class="form-group">
<label class="control-label col-sm-2" for="First Name">First Name:</label>
<div class="col-sm-10">
<input type="text" name="FirstName" class="form-control" id="First Name" placeholder="First Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Last Name">Last Name:</label>
<div class="col-sm-10">
<input type="Last Name" name="LastName" class="form-control" id="Last Name" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Company Name">Company Name:</label>
<div class="col-sm-10">
<input type="Company Name" name="CompanyName" class="form-control" id="Company Name" placeholder="Company Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="Email" name="Email" class="form-control" id="Email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Message">Message</label>
<div class="col-sm-10">
<textarea type="Message" name="Message" class="form-control" rows="3" columns="50" id="Message" placeholder="Message"></textarea></div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button name="submit" class="submit-btn" type="submit">Submit</button>