in Bootstrap4- I need to submit Modal Form using php - php

I am building this website for a takeaway restaurant and the client requested 2 models one for career (receiving the resumes ) and the other for subscription to email updates.
How can I let the Form of the MODEL send the data to a Php page for GET_POST ?
The reason I am asking this is I need to record all the Model data to a database of the server not only send an email with the data.
First Model #join us
<div class="modal" id="JoinModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Subscribe for our updates</h5>
<button class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form action="addmail.php" method="post">
<div class="form-group">
<label for="username">Name</label>
<input type="text" id="fname" placeholder="Name" class="form-control">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" placeholder="Email" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" value="Submit">Join</button>
</div>
</div>
</div>
</div>
The other model for receiving the resumes
<!-- Career MODAL -->
<div class="modal" id="CareerModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Join our Team</h5>
<button class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="username">Name</label>
<input type="text" placeholder="Name" class="form-control">
</div>
<div class="form-group">
<label for="familyname">Family Name</label>
<input type="text" placeholder="Family Name" class="form-control">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<label for="cv">Attach your CV</label>
<input type='file' name='cv' id='cv' class='form-control' ><br>
<input type='button' class='btn btn-info' value='Upload' id='upload'>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" value="Submit">Apply</button>
</div>
</div>
</div>
</div>
</div>

you can use ajax that will help you to perform parallel operation
e.g : inserting to database and sending mail
hope, it works for you

Related

Adding a confirmation pop up when submitting record with laravel

I am making an add button and when clicked it brings up a modal where data can be entered but when clicked, this record gets sent through and to avoid mistakes, I wish to add a confirmation(yes or no) pop up to make sure the user is certain on submitting. Has anyone worked with this before?
Heres my modal code:
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Subject add</h5>
</div>
<form action="/test/save-subject" method="POST">
{{ csrf_field() }}
<div class="modal-body">
<div class="mb-3">
<label for="recipient-name" class="col-form-label">Subject ID:</label>
<input type="text" name="subjectcode" class="form-control" id="recipient-name" maxlength="6" style="text-transform:uppercase" required>
</div>
<div class="mb-3">
<label for="message-text" class="col-form-label">Description:</label>
<textarea name="detail" class="form-control" id="message-text" required></textarea>
</div>
<div class="mb-3">
<label for="recipient-name" class="col-form-label">Email Address:</label>
<input type="text" name="emailaddress" class="form-control" id="recipient-name" required>
</div>
<div>
<input type="checkbox" name="staff" value="1"> <label>Staff Update</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add</button>
</div>
</form>
</div>
</div>
</div>

Is it possible to change the segment(3) which is the ID in my url into a random string(Codeigniter)?

I tried to change the $config['url_suffix'](that is located at my config/config) into $config['url_suffix'] = ''; . I encountered an error, it says that "Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster." And I also tried to put the random_string in my view, may update is not working now
Config file
$config['url_suffix'] = '<?= random_string(40?>';
View
<a data-toggle="modal" class="btn btn-warning" data-target="#update_account-<?= $profileAccount->id?>"><span class="glyphicon glyphicon-edit"></span>Edit</a>
<div class="modal fade" id="update_account-<?= $profileAccount->id?>" tabindex="-1" role="dialog" aria-labelledby="titleLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header modal-header-success">
<button type="button" class="close btn btn-primary" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="titleLabel">Update Profile</h4>
</div>
<div class="modal-body">
<div class="container">
<div clas="row">
<form method="post" action="<?= base_url(). 'User/updateProfile/'.random_string($profileAccount->id)?>">
<div class="col-md-5 col-lg-5">
<?= validation_errors();?>
<div class="form-group">
<label>ID</label>
<input type="text" disabled value="<?= $profileAccount->id?>" class="form-control">
</div>
<div class="form-group">
<label>First Name</label>
<input type="text" name ="fname"value="<?= $profileAccount->first_name?>" class="form-control">
</div>
<div class="form-group">
<label>Middle Name</label>
<input type="text" name ="mname" value="<?= $profileAccount->middle_name?>" class="form-control">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name ="lname" value="<?= $profileAccount->last_name?>" class="form-control">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name ="email" value="<?= $profileAccount->email?>" class="form-control">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name ="password" class="form-control">
</div>
<div class="form-group">
<label>Contact Number</label>
<input type="text" name ="phone" value="<?= $profileAccount->phone?>" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<span class="pull-right">
<button type="submit" class="btn btn-success">Update Event</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</span>
</form>
</div>
</div>
</div>
</div>
Your config has missing character the closing parenthesis )
change this
$config['url_suffix'] = '<?= random_string(40?>';
to
$config['url_suffix'] = '<?= random_string(40)?>';
If not working I think your random_string function has an error

Displaying data from database in bootstrap modal form(PHP&MySQL)

I am new to both bootstrap and php. I have created a registration modal form to register users for my site and it registers perfectly. However, I would like to retrieve a users details from my database based on their User ID and display their details in a registration form for them to edit and update.
What I don't know how to do is display the records in the form fields...
Please help by providing a simple syntax for this.
I am using PHP and MySql
This is my modal form
<div class="modal fade" id="updatelecModal" tabindex="-1" role="dialog" aria-labelledby="updatelecModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<!--End of modal-->
<!-- Start of form-->
<form id="updatelecForm" class="form-horizontal" role="form" method="post" action="#" nonvalidate>
<div class="form-group">
<label for="student_id" class="col-sm-3 control-label">Lecturer ID</label>
<div class="col-lg-9">
<input type="text" class="form-control" name="lec_id" required placeholder="Enter User ID">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Full name</label>
<div class="col-lg-4">
<input type="text" class="form-control" name="firstName" required placeholder="First name" />
</div>
<div class="col-lg-4">
<input type="text" class="form-control" name="lastName" required placeholder="Last name" />
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-lg-9">
<input type="email" class="form-control" name="lec_email" required placeholder="#######.com">
</div>
</div>
<label class="col-xs-3 control-label" name="lec_gender">Gender:</label>
<label class="radio-inline control-label">
<input type="radio" name="optionsRadio" id="gender" value="Male">Male
</label>
<label class="radio-inline control-label">
<input type="radio" name="optionsRadio" id="gender" value="Female">Female
</label>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Password</label>
<div class="col-sm-7">
<input type="password" id="password" class="form-control" name="password" required placeholder ="Enter your Password">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Confirm Password</label>
<div class="col-sm-7">
<input type="password" id="password2" class="form-control" name="cpassword" data-validate-linked="password" required placeholder ="Re-enter your Password">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Register</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
</form>
<!--End of registration form-->
</div>
</div>
</div>
</div>
I dont know how to include the php in this form as it disappears
Also if you could include links for further reading on php I would really appreciate.
Without seeing any code it's difficult to give more specific help. However, what I would do is store the user's id in a session. When they view the form brab the id from the session and do a SQL call to your db, something like:
SELECT firstName,lastName,email, FROM table_name WHERE id=$id
Obviously what you select, the table_name, and the where clause depends on your own tables and variables.
Run your SQL command and store the columns into variables. Then place the variable into the value of the input:
<input type="text" value="<?php echo $name != '' ? $name : ''; ?>" />
Basically, what I did above is a shorthand if statement that says if $name isn't blank they print it, otherwise print nothing.

Repeatation of block of Html if html structure not in loop

I have a list of product on mypage each product is having a enquiry button on it.
By clicking enquiry button bootstrap pop up opens.
I want that form to work for every product with product id of each product
I have achieved this by putting bootstrap pop up model in loop
my Question is. Instead of repeation blok of bootstrap pop up model , instead of keeping popup html in loop,is it possible to achieve this with function and keeping popup html outside loop ?
<?php if(isset($ser_gal)){
$gal_count =1;
foreach($ser_gal as $s){?>
<div class="element">
<div class="tz-inner" >
<div class="tz-image-item"> <img alt="" src="<?php echo URL;?>gallery/thumbs/thumb_<?php echo $s->IMAGE_PATH ; ?>"> </div>
<h6><?php echo $s->interior_cat;?></h6>
<hr />
<div class="cl"></div>
<?php echo $s->title;?>
<div align="center" >Enquiry</div>
</div>
</div>
<!--form-->
<div class="bs-example">
<div id="myModal<?php echo $gal_count;?>" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Enquiry</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="recipient-name" class="control-label">Name</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Email Id</label>
<input type="text" class="form-control texttrans_none" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Mobile No</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Product</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!---->
<?php $gal_count++;} }?>

Form in Bootstrap modal not posting PHP values to another page

I am using a form in a bootstrap modal window to post data to another page. However when i try to print the post values on the other page all I am getting is an empty array.
Here's my modal code:
<div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
X</button>
<h3 id="myModalLabel">
Enter your Credentials</h3>
</div>
<div class="modal-body">
<form id="modal-form" class="form-horizontal" accept-charset="UTF-8" method="POST" action="login.php" data-remote="true">
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="email" id="email" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" id="passwd" placeholder="Password">
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<input type="submit" class="btn btn-primary" value="Submit"/>
Sign up
</div>
</div>
</form>
</div>
</div>
Here's the command I'm giving in login.php:
echo "Email is:";
echo $_POST["email"];
echo "Password is:";
echo $_POST["passwd"];
However all I'm getting is an empty array.
Is there some sort of special way I'm supposed to do this?
You have't define name in input just change two line from your code. add name of that input.
<input type="email" id="email" name="email" placeholder="Email" />
<input type="password" id="passwd" name="passwd" placeholder="Password" />

Categories