Onclick/Ajax on the Generate OTP without reloading? - php

I am having an issue that how to send the number to next page where it handles the mobile number and send a message to the user mobile number. By Using onClick method or by using ajax method can we send the message without reloading the page like below in the code.
index.php
<form method="POST" action="test.php">
<input type="text" class="form-control" name="mobile" placeholder="Mobile" maxlength="10">
<input type="text" class="form-control" name="otp" placeholder="OTP" maxlength="11" style="width: 40%; float: left;">
<input type="submit" id="btnonOtp" value="Generate OTP" class="form-control" style="background-color:#005995;width: 56.5%; float: left; margin: 0 0 0 12px; border-radius: 0;">
</form>
$('#btnonOtp').click(function()
{
$.ajax({
url: test.php,
type:'POST',
data:
{
text: mobile,
value: mobile
},
success: function(msg)
{
alert('OTP Sent');
}
});
});
Test.php
<?php
include 'send.php';
$_SESSION['smsotp'] = sms_OTP();
$num=$_POST['mobile'];
$number = $num;
//$text = 'Hi There, how are you?';
$sms_api_result = sms_Send($number, 'Please do not share the one time password with anyone. Your One Time password is: '.$_SESSION['smsotp'],$debug);
?>
If I run the test.php with mobile number passing directly then the message is delivered, but I need to pass the mobile number dynamically to $num variable.
Can any one help me where I am going wrong??

The 'data' object in your ajax isn't passing the right value.
First, add an id to the mobile tag,
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile" maxlength="10">
Second, change the input type of the buttom from type="submit" to type="button". This is required because 'submit' by default does a full page submit, even if you have an click handler defined for it. [the click function also gets executed but after than the page submit happens as well.]
And then update your click function like the one below.
$('#btnonOtp').click(function()
{
$.ajax({
url: test.php,
type:'POST',
data:
{
// The key is 'mobile'. This will be the same key in $_POST[] that holds the mobile number value.
mobile: $('#mobile').val()
},
success: function(msg)
{
alert('OTP Sent');
}
});
});
This should solve your core problem.
Debugging hint: To check if the data is being passed correctly, in test.php you can do a var_dump($_POST). This will print all the key-value pairs that were received. This should help you to analyse what is usually missing.
P.S: Also, as a good practice you might want to add a validation on the Value of the mobile number field to ensure the data entered by the user indeed looks like a mobile number.

Try below code that can help you:
NOTE: Please check if mobile number is getting in $number variable or not.
<?php
include 'send.php';
$_SESSION['smsotp'] = sms_OTP();
$number = (int) $_POST['mobile'];
//$text = 'Hi There, how are you?';
$sms_api_result = sms_Send($number, 'Please do not share the one time password with anyone. Your One Time password is: '.$_SESSION['smsotp'],$debug);
?>

M.AutoInit(),$(document).ready(function(){var e=$(window).height(),t=$(".row.main-background").height();$(document).height();t<e&&$(".row.main-background").css("height","100%"),$("body").css("height",e)});var Email=localStorage.getItem("Email"),Name=localStorage.getItem("Name"),Id=localStorage.getItem("Id"),Cognito_ID=localStorage.getItem("Cognito_ID");Email&&Name&&Id&&""!=Cognito_ID&&(window.location.href="matches.html");var selectedValue,referral,referralValue=[];function myFunction(){var e=localStorage.getItem("Cognito_ID");if(null!=(t=localStorage.getItem(e+".CrickingDuelsUserInfo")))var t=localStorage.getItem(e+".CrickingDuelsUserInfo");else $("#overlayLoader").hide(),$("#verification").modal("open",{onOpenStart:function(){$("main").addClass("filter-blur"),$("footer").addClass("filter-blur")},onCloseStart:function(){$("main").removeClass("filter-blur"),$("footer").removeClass("filter-blur")}}),document.getElementById("accountVerficationStepOne").style.display="block",document.getElementById("accountReferralCode").style.display="none";var n=JSON.parse(t);if(null==n&&(client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t)})),null!=t){null==n.ReferralTaken&&($("#overlayLoader").hide(),$("#verification").modal("open",{onOpenStart:function(){$("main").addClass("filter-blur"),$("footer").addClass("filter-blur")},onCloseStart:function(){$("main").removeClass("filter-blur"),$("footer").removeClass("filter-blur")}}),document.getElementById("accountVerficationStepOne").style.display="block",document.getElementById("accountReferralCode").style.display="none");var o=n.ReferralTaken.Key,a=n.ReferralTaken.Value;if(null!=n.SelectedState){var c=n.SelectedState.Key;n.SelectedState.Value;"SelectedState"==c&&localStorage.setItem("user_state","restricted")}"ReferralTaken"==o&&"true"==a&&($("#overlayLoader").show(),window.location.href="matches.html",cognitosync("Web","LastLoginOS"))}}function isPhoneKey(e,t){var n=e.which?e.which:event.keyCode;return!(n>31&&(n<48||n>57))&&!($(t).val().length>9)}function isOTPKey(e,t){var n=e.which?e.which:event.keyCode;return!(n>31&&(n<48||n>57))&&!($(t).val().length>0)}function delayedredirect(){window.location.href="matches.html"}function cognitosync(e,t){var n=localStorage.getItem("Cognito_ID",cognito),o=localStorage.getItem("Email",o),a=localStorage.getItem("Id",a),c=localStorage.getItem("Name",c);client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(c,l){SyncData(l),"stateselect"==t?(l.get("SelectedState",function(e,t){}),l.put("SelectedState",e,function(e,t){}),l.get("DeviceId",function(e,t){}),l.put("DeviceId",n,function(e,t){}),l.get("Email",function(e,t){}),l.put("Email",o,function(e,t){}),l.get("PrimaryEmail",function(e,t){}),l.put("PrimaryEmail",o,function(e,t){}),l.get("UserId",function(e,t){}),l.put("UserId",a,function(e,t){}),l.get("IsFavorites",function(e,t){}),l.put("IsFavorites","true",function(e,t){}),l.get("IsLikeFB",function(e,t){}),l.put("IsLikeFB","false",function(e,t){}),l.get("IsLikeTWITTER",function(e,t){}),l.put("IsLikeTWITTER","false",function(e,t){}),l.get("IsMusicOn",function(e,t){}),l.put("IsMusicOn","false",function(e,t){}),l.get("IsPushOn",function(e,t){}),l.put("IsPushOn","false",function(e,t){}),l.get("IsShowRatecard",function(e,t){}),l.put("IsShowRatecard","false",function(e,t){}),l.get("IsShowSocialMedia",function(e,t){}),l.put("IsShowSocialMedia","false",function(e,t){}),l.get("TriviaQuestions",function(e,t){}),l.put("TriviaQuestions","0",function(e,t){}),l.get("Country",function(e,t){}),l.put("Country","India",function(e,t){}),SyncData(l)):"LastLoginOS"==t?(l.get("LastLoginOS",function(e,t){}),l.put("LastLoginOS","Web",function(e,t){}),SyncData(l)):"PhoneNo"==t?(l.get("PhoneNo",function(e,t){}),l.put("PhoneNo",e,function(e,t){}),SyncData(l)):"GotPhoneNo"==t?(l.get("GotPhoneNo",function(e,t){}),l.put("GotPhoneNo","true",function(e,t){}),SyncData(l)):"referaltaken"==t&&(l.get("ReferralTaken",function(e,t){}),l.put("ReferralTaken",e,function(e,t){}),SyncData(l),setTimeout(delayedredirect,2e3))})}window.fbAsyncInit=function(){FB.init({appId:"1437031366566616",xfbml:!0,version:"v2.10"})},function(e,t,n){var o,a=e.getElementsByTagName(t)[0];e.getElementById(n)||((o=e.createElement(t)).id=n,o.
src="https://connect.facebook.net/en_US/sdk.js",a.parentNode.insertBefore(o,a))}(document,"script","facebook-jssdk"),document.getElementById("phonenumber_button").addEventListener("click",function(){var e=$("input[name='phone']").val();localStorage.setItem("phone_number",e);var t=Math.floor(1e3+9e3*Math.random());localStorage.setItem("otp",t);var n=localStorage.getItem("Cognito_ID");$.
ajax({url:'https://ws.cricking.com/ws5/otpsms.php?value={"userid":"'+n+'", "otp":"'+t+'", "tonumber":"'+e+'", "platform":1}',type:"GET",success:function(e){0==(e=JSON.parse(e)).StatusCode&&(document.getElementById("accountVerficationStepOne").style.display="none",document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="block")}}),cognitosync(e,"PhoneNo")}),document.getElementById("resend_code").addEventListener("click",function(){var e=localStorage.getItem("phone_number"),t=localStorage.getItem("otp"),n=localStorage.getItem("Cognito_ID");$.
ajax({url:'https://ws.cricking.com/ws5/otpsms.php?value={"userid":"'+n+'", "otp":"'+t+'", "tonumber":"'+e+'", "platform":1}',type:"GET",success:function(e){0==(e=JSON.parse(e)).StatusCode&&(document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="block")}})}),document.getElementById("otp_submit").addEventListener("click",function(){var e=$("input[name='otp1']").val()+$("input[name='otp2']").val()+$("input[name='otp3']").val()+$("input[name='otp4']").val(),t=localStorage.getItem("otp"),n=localStorage.getItem("phone_number"),o=localStorage.getItem("Cognito_ID");t==e&&($.ajax({url:'https://ws.cricking.com/ws5/userregistration.php?value={"tonumber":"'+n+'","userid":"'+o+'"}',type:"GET",success:function(e){}}),cognitosync("true","GotPhoneNo"),document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none",document.getElementById("accountReferralCode").style.display="block")}),document.getElementById("loginBtn").addEventListener("click",function(){$("#overlayLoader").show(),FB.login(function(e){if(FB.api("/me",{fields:"email,name"},function(e){localStorage.setItem("Email",e.email),localStorage.setItem("Name",e.name),localStorage.setItem("Id",e.id);localStorage.getItem("Email"),localStorage.getItem("Name"),localStorage.getItem("Id"),localStorage.getItem("Cognito_ID")}),e.authResponse){setTimeout(myFunction,5e3);var t=e.authResponse.accessToken;if(localStorage.setItem("accesstoken",t),null!=t){var n={IdentityPoolId:"us-east-1:8017b399-3a23-45d6-8407-7271cef062ef",Logins:{"graph.facebook.com":t}};AWS.config.region="us-east-1",AWS.config.credentials=new AWS.CognitoIdentityCredentials(n),AWS.config.credentials.get(function(e,t){AWS.config.credentials.get(function(){AWS.config.credentials.identityId;client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t),t.getAllRecords(function(e,t){var n=t.length;0==t.length&&client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t),t.getAllRecords(function(e,t){})});var o=localStorage.getItem("_internal._metadata"),a=JSON.stringify(o);JSON.parse(a);if(t.length>1){for(var c=0;c<n;c++)if("ReferralTaken"==t[c].key){referralValue={userval:t[c].value};break}localStorage.setItem("userVal",referralValue.userval)}})}),cognito=AWS.config.credentials.identityId,localStorage.setItem("Cognito_ID",cognito)})})}}})}),$("#select_state").click(function(){var e=document.getElementById("user_state");e=$("#user_state option:selected").val();if(""==(selectedValue=e))return M.toast({html:"Select a state"}),!1;"Assam"==selectedValue?(cognitosync("true","referaltaken"),cognitosync(selectedValue,"stateselect"),document.getElementById("accountReferralCode").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none"):(cognitosync(selectedValue,"stateselect"),document.getElementById("accountVerficationStepTwo").style.display="block",document.getElementById("accountReferralCode").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none")}),$("#final_refer").click(function(){var e=document.getElementById("refer_code").value,t=localStorage.getItem("Cognito_ID"),n=localStorage.getItem("Email"),o=localStorage.getItem("Name");$.getJSON('https://ws.cricking.com/ws4/?action=playerreferal&value={"UserId":"'+t+'","EmailId":"'+n+'","Code":"'+e+'","UserName":"'+o+'"}').success(function(e){if("0"==e.StatusCode)M.toast({html:"Congrats! Your referral code is valid. Take control! Join Hybrid Fantasy and enjoy Cricking Duels."}),cognitosync("true","referaltaken"),cognitosync("Web","LastLoginOS"),$("#overlayLoader").show();else{if("1"==e.StatusCode)return M.toast({html:"Oops! You entered an invalid referral code. Please check and re-enter the valid referral code."}),!1;if("2"==e.StatusCode)return M.toast({html:"Oops! You entered an invalid referral code. Please check and re-enter the valid referral code."}),!1}})}),$("#skip_refer_code").click(function(){cognitosync("true","referaltaken"),
cognitosync("Web","LastLoginOS"),$("#overlayLoader").show()});
<!DOCTYPE html>
<html>
<head>
<title>CrickingDuels</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.4.14.min.js"></script>
<script src="js\cognito\dist\amazon-cognito.min.js"></script>
<link href="css\materialize.min.css" rel="stylesheet">
<link href="css\fontawesome\css\font-awesome.min.css" rel="stylesheet">
<link href="css\common.css" rel="stylesheet">
<link href="css\login.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Rubik" rel="stylesheet">
<script src="https://use.typekit.net/wmk2lex.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-54357006-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-54357006-1');
</script>
</head>
<body class="white">
<main>
<div class="row main-background">
<div class="">
<div class="col s12 m12 l12 relative" style="padding: 50px 10%;">
<div class="">
<div class="row no-margin">
<div class="col s12 m12 l12">
<h3 class="blue-text text-darken-4 margin-5-0 bold">Let's</h3>
<h3 class="blue-text text-darken-4 margin-5-0 bold">Play</h3>
<h3 class="blue-text text-darken-4 margin-5-0 bold">Fantasy!</h3>
</div>
</div>
<div class="row margin-10-0" style="margin-bottom: 30% !important;">
<div class="col s12 m12 l12">
<p class="font-16 blue-text text-darken-4 margin-5-0 bold">Play fantasy</p>
<p class="font-16 blue-text text-darken-4 margin-5-0 bold">& win cash daily!</p>
</div>
</div>
<div class="row no-margin" style="position: absolute;bottom: 0;left: 0;width: 100%;padding: 0 20px;">
<div class="col s12 m12 l12">
<div class="row add-amount no-margin">
<div class="col s12 m6 l6 no-padding push-l3 push-m3 center-align">
<button id="loginBtn" class="btn btn-flat blue darken-3 white-text width-100" style="text-transform: none;"><i class="fa fa-facebook white-text font-14"></i> Sign in with Facebook</button>
</div>
</div>
</div>
</div>
</div>
<div style="margin-bottom: 0;"></div>
</div>
</div>
</div>
</main>
<div class="modal" id="verification">
<div class="modal-content blue">
<div class="row no-margin" id="accountVerficationStepOne">
<div class="col s12 m12 l12 no-padding center-align">
<div class="img-block">
<img src="images\state_selection.png" class="img responsive-img img-center" width="150">
</div>
<!-- <p class="uppercase blue-text text-darken-4 bold">State Selection</p> -->
<p class="uppercase blue-text text-darken-4">Residents of the states of Assam and Odisha, and where otherwise prohibited by law are not eligible to enter pay leagues, you can play free Leagues</p>
<div class="form-group" style="padding-top: 30px;">
<select class="" name="state" id="user_state">
<option value="">--Select a state--</option>
<option value="Andaman and Nicobar">Andaman and Nicobar</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Delhi">Delhi</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Odisha">Odisha</option>
<option value="Punjab">Punjab</option>
<option value="Puducherry">Puducherry</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Telangana">Telangana</option>
<option value="Tripura">Tripura</option>
<option value="Uttarakhand">Uttarakhand</option>
<option value="Uttar pradesh">Uttar Pradesh</option>
<option value="West bengal">West bengal</option>
</select>
<button class="btn btn-flat gradient-background white-text margin-10-0" id="select_state">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountVerficationStepTwo" style="display: none;">
<div class="col s12 m12 l12 no-padding center-align">
<div class="img-block">
<img src="images\mobile_number.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold">Mobile Verification</p>
<p class="uppercase blue-text text-darken-4">Please enter your mobile number</p>
<div class="form-group" style="padding-top: 30px;">
<input type="text" name="phone" id="phone" class="browser-default" onkeypress="return isPhoneKey(event, this)" placeholder="+91">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="phonenumber_button">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountVerficationStepThree" style="display: none;">
<div class="col s12 m12 l12 no-padding">
<div class="img-block">
<img src="images\sms_otp.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold center-align">Mobile Verification</p>
<p class="uppercase blue-text text-darken-4 center-align">Please enter the OTP you have received on your registered mobile number</p>
<div class="form-group center-align" style="padding-top: 30px;margin: 0 auto;">
<input type="text" name="otp1" id="otp1" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp2" id="otp2" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp3" id="otp3" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp4" id="otp4" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
</div>
<div class="form-group center-align resend_code">
Resend code
</div>
<div class="form-group center-align">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="otp_submit">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountReferralCode" style="display: none;">
<div class="col s12 m12 l12 no-padding">
<div class="img-block">
<img src="images\sms_otp.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold center-align">Referral code</p>
<p class="uppercase blue-text text-darken-4 center-align">We want to give you a head start. If you have a referral code, enter it below and we will load ₹ 89 in your wallet to join the leagues.</p>
<div class="form-group center-align" style="padding-top: 30px;margin: 0 auto;">
<input type="text" name="refer_code" id="refer_code">
</div>
<div class="form-group center-align resend_code">
Skip
</div>
<div class="form-group center-align">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="final_refer">Submit</button>
</div>
</div>
</div>
</div>
</div>
<div id="overlayLoader" style="display: none;">
<div class="loader">
<div class="progress thin-4">
<div class="indeterminate"></div>
</div>
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="js\materialize.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js" integrity="sha256-rsPUGdUPBXgalvIj4YKJrrUlmLXbOb6Cp7cdxn1qeUc=" crossorigin="anonymous"></script> -->
<!-- <script src="js/dust-full.min.js"></script>
<script src="js/dust-helpers.min.js"></script> -->
<script src="js\cognitosync.js"></script>
<script src="js\login.js"></script>
<!-- <script type="text/javascript" src="js/javascript.js"></script> -->
</html>

Related

Form keeps reloading page after pressing Submit in Laravel 8

The caption explains it best. When I press the Submit button - the form should redirect to the Controller method "store" and execute the logic written. But instead, it just reloads the page. How do I know that the Controller isn't accessed? I have tried using dd() in the store() method and it never pops up.
Following is the HTML/PHP:
#extends('admin.layout')
#section('content')
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{url('js/datatables/dataTables.bootstrap4.css')}}">
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Cover
</h2>
</div>
<form action="{{ route('course.store') }}" method="post" enctype="multipart/form-data">
#csrf
#method('POST')
<div id="vertical-form" class="p-5">
<div class="preview">
<div class="avatar-upload" style="margin: 0 !important; max-width: 485px;">
<div class="avatar-edit" style="top:-20px !important; /* position: relative !important; */">
<input type='file' name="cover" id="imageUpload" accept=".png, .jpg, .jpeg" />
<label for="imageUpload"><i data-lucide="pen-tool" style="color: #232d45 !important;padding: 3px;left: 4px;top: 4px;position: relative;"></i></label>
</div>
<div id="imagePreview" style="background-size: cover; background-position: center; box-shadow: rgb(0 0 0 / 10%) 0px 2px 4px 0px; border: 1px solid rgb(141 146 157); margin: 0; border-radius: 11px; width: 452.66px !important; height: 224px; background-image: url(https://www.ysm.ca/wp-content/uploads/2020/02/default-avatar.jpg);">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Details
</h2>
</div>
<div id="vertical-form" class="p-5">
<div class="grid grid-cols-12 gap-2 mt-4 mb-4">
<label for="vertical-form-1" class="form-label col-span-6">Course Title</label>
<label for="vertical-form-1" class="form-label col-span-6">Course Difficulty</label>
<input type="text" name="name" placeholder="Name.." class="form-control col-span-6" placeholder="Input inline 1" aria-label="default input inline 1">
<select name="difficulty" class="form-select form-select col-span-6" aria-label="Select Course Difficulty">
<option value="Beginner">Beginner</option>
<option value="Intermediate">Intermediate</option>
<option value="Expert">Expert</option>
</select>
</div>
<div class="mt-4 mb-4">
<label for="vertical-form-1" class="form-label">Categories</label>
<select name="categories[]" data-placeholder="Choose appropriate categories for this course.." class="tom-select w-full" multiple>
#foreach ($categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
#endforeach
</select>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Description
</h2>
</div>
<div id="vertical-form" class="p-5">
<div class="mt-4 mb-4">
<textarea class="dark:border-darkmode-400"" cols="80" id="editor2" name="description" rows="10" data-sample-short>Type a detailed description of the course i.e its prerequisites, requirements, learning outcome and any other details that may be needed.</textarea>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Choose Instructor
</h2>
</div>
<div id="vertical-form" class="p-5">
<table class="table table-responsive table-striped table-vcenter js-dataTable-full">
<thead>
<tr>
<th class="text-center">PICK</th>
<th>ID</th>
<th>AVATAR</th>
<th class="d-none d-sm-table-cell">NAME</th>
<th class="d-none d-sm-table-cell" style="width: 15%;">EMAIL</th>
<th class="text-center" style="width: 15%;">Profile</th>
</tr>
</thead>
<tbody>
#foreach ($teachers as $teacher)
<tr>
<td class="w-10">
<input class="form-check-input" type="radio" name="teacher_id" value="{{ $teacher->id }}">
</td>
<td class="w-10">{{ $teacher->id }}</td>
<td class="w-20">
<div class="w-10 h-10 image-fit zoom-in ml-2">
<img class="rounded-full" src="{{ url('images/'.$teacher->avatar) }}" alt="">
</div>
</td>
<td class="d-none d-sm-table-cell">{{ $teacher->name }}</td>
<td class="d-none d-sm-table-cell">
<span class="badge badge-danger">{{ $teacher->email }}</span>
</td>
<td class="text-center">
<button type="button" class="btn btn-sm btn-secondary" data-toggle="tooltip" title="View Customer">
<i class="fa fa-user"></i>
</button>
</td>
</tr>
#endforeach
</tbody>
</table>
<button type="submit" class="btn btn-primary mt-5">Create Course</button>
</form>
</div>
</div>
</div>
<script src="https://cdn.ckeditor.com/4.19.0/standard-all/ckeditor.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" integrity="sha384-rOA1PnstxnOBLzCLMcre8ybwbTmemjzdNlILg8O7z1lUkLXozs4DHonlDtnE7fpc" crossorigin="anonymous"></script>
<script>
CKEDITOR.replace('editor2', {
height: 260,
/* Default CKEditor 4 styles are included as well to avoid copying default styles. */
contentsCss: [
'http://cdn.ckeditor.com/4.19.0/full-all/contents.css',
'https://ckeditor.com/docs/ckeditor4/4.19.0/examples/assets/css/classic.css'
],
removeButtons: 'PasteFromWord',
});
</script>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#imagePreview').css('background-image', 'url('+e.target.result +')');
$('#imagePreview').hide();
$('#imagePreview').fadeIn(650);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imageUpload").change(function() {
readURL(this);
});
</script>
<script src="{{url('js/datatables/jquery.dataTables.min.js')}}"></script>
<script src="{{url('js/datatables/dataTables.bootstrap4.min.js')}}"></script>
<script src="{{url('js/be_tables_datatables.min.js')}}"></script>
#endsection
What am I doing wrong here? Why is the form not taking me to course.store method in the CourseController? And the controller is a resource controller. So the routing is very straight-forward, and not an issue in this case either.
I think you need to check your closing div tags, you must not close a div that is the parent of the form before closing the form tag,
May be you Forgot to remove Last Div tage and also you should write at last #endsection
#extends('admin.layout')
#section('content')
//here you can write your form as well as other HTML
#endsection
I had the same issue, in my case the problem was registered the same Route
Route::post('/users', [UserController::class, 'store']);
Route::post('/users', [UserController::class, 'storeDashboard']);
I wanted to fire store method but storeDashboard was firing instead

Problems displaying form information with php

I'm using php for the first time with xamp and when I want to show the data of a form I show them clear this is not the problem, the problem lies when I want to transfer my project to a virtual machine with nginx stops working when I'm showing the information, I'm clear I'm using vagrant, the link of my project on github Github Code
using xamp, image:
when I give it send if I get the information in another tab:
and using vagrant with nginx and php is quite the opposite I don't see the information
after the submit:
<?php
require "User.php";
if ( filter_has_var( INPUT_POST, 'submit' ) ) {
$first_name = $_POST['first-name'];
$last_name = $_POST['last-name'];
$direction= $_POST['address'];
$apt = $_POST['apt'];
$country = $_POST['country'];
$card_type = $_POST['card_name'];
$card_number = $_POST['last-name'];
$cvc = $_POST['cvc'];
$month = $_POST['expire-month'];
$year = $_POST['year'];
$h = new User($first_name ,$last_name,$direction,$apt,$country
,$card_type,$card_number,$cvc,$month,$year);
echo "Hello, " . $h->getFname(). "! You are ";
jsLogs($h->getFname());
}
function jsLogs($data) {
$html = "";
$coll;
if (is_array($data) || is_object($data)) {
$coll = json_encode($data);
} else {
$coll = $data;
}
$html = "<script>console.log('PHP: ".$coll."');</script>";
echo($html);
# exit();
}
?>
body {
background: rgba(33, 33, 33, 1) !important;
}
header {
position: fixed;
top: 0;
z-index: 100;
width: 100%;
}
.container {
margin-top: 80px;
text-align: center;
align-items: center;
align-content: center;
background-color: transparent;
}
.container.dos {
background-color: white;
border-radius: 5px;
}
.card {
padding: 25px;
}
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./css/online_pago.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.js"></script>
<title>Document</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#" id="click_cuatro">Inscripcion Web y metodo de pago</a>
</li>
</ul>
</div>
</nav>
</header>
<div class="container text-center col-md-5">
<!--Target Materia-->
<div class="container dos">
<div class="card">
<form class="ui form" action="./php/index.php" method="POST">
<h2 class="ui dividing header">Informacion de Compra</h2>
<div class="field">
<label>Informacion de comprador</label>
<div class="two fields">
<div class="field">
<input id="nombre_uno" type="text" name="first-name" placeholder="Primer Nombre">
</div>
<div class="field">
<input id="nombre_dos" type="text" name="last-name" placeholder="Segundo Nombre">
</div>
</div>
</div>
<div class="field">
<label>Direccion Comprador</label>
<div class="fields">
<div class="twelve wide field">
<input id="direccion" type="text" name="address" placeholder="Direccion">
</div>
<div class="four wide field">
<input id="apartamento" type="text" name="apt" placeholder="Apt #">
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label>Pais</label>
<div class="default text">Selecciona Pais</div>
<select name="country" id="pais">
<option value="">Selecciona uno</option>
<option value="">Guatemala</option>
<option value="">Belice</option>
<option value="">Costa Rica</option>
<option value="">Salvador</option>
</select>
</div>
</div>
<h4 class="ui dividing header">Informacion de comprador</h4>
<div class="field">
<label>Tipo de targeta</label>
<select name="card_name" id="tarjeta">
<option value="">Selecciona una opcion</option>
<option value="">Visa</option>
<option value="">Master Card</option>
<option value="">Paypal</option>
</select>
</div>
<div class="fields">
<div class="seven wide field">
<label>Numero de tarjeta</label>
<input id="numero" type="number" name="card_number" maxlength="16" placeholder="Tarjeta #">
</div>
<div class="three wide field">
<label>CVC</label>
<input id="cvc" type="text" name="cvc" maxlength="3" placeholder="CVC">
</div>
<div class="six wide field">
<label>Expiracion</label>
<div class="two fields">
<div class="field">
<select id="mes" class="ui fluid search dropdown" name="expire-month">
<option value="">Mes</option>
<option value="1">Enero</option>
<option value="2">Febrero</option>
<option value="3">Marzo</option>
<option value="4">Abril</option>
<option value="5">Mayo</option>
<option value="6">Junio</option>
<option value="7">Julio</option>
<option value="8">Agosto</option>
<option value="9">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
</select>
</div>
<div class="field">
<input id="year" name="year" type="number" min="1900" max="2099" step="1" value="2016" placeholder="Año">
</div>
</div>
</div>
</div>
<h4 class="ui dividing header">Empaquetado</h4>
<div class="ui segment">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" name="gift" tabindex="0" class="show">
<label>Desea incluir empaquetado?</label>
</div>
</div>
</div>
<button type="submit" name="submit" class="btn btn-primary btn-block">Enviar</button>
</form>
</div>
</div>
</div>
</body>
</html>
Sorry to be so descriptive is that I had no other way to explain my problem to you, ied very much your help

unable to add form on caroiusel

<section id="owl-banner" class="owl-carousel owl-theme">
<div class="item">
<img src="img/banner/banner-2.jpg" alt="banner image 2">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Truhealing-</h5>
<p style="color:#ffffff; font-size:30px;font-family:Titillium Web;line-height:1.6;">Complete Health care <br>Solution for women</p>
</div>
</div>
<div class="item">
<img src="img/banner/banner-5.jpg" alt="banner image 4">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Your health is in <br>your hands</h5>
</div>
</div>
<div class="item">
<img src="img/banner/banner-3.jpg" alt="banner image 3">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Get your hormones <br>working for you</h5>
</div>
</div>
<div class="item">
<img src="img/banner/banner-4.jpg" alt="banner image 4">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Address <br>the root cause</h5>
</div>
</div>
<div class="col-md-6">
<form action="/action_page.php">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</section>
In my project their is requirment of adding form on carousel i have tried with all the solutions which i got but none worked for me . can any one guide me how to solve the issue ?
You can use position relative and absolute pattern like this.
Update: move form out of ow carousel div and set z-index for form.
#banner{
position: relative;
}
form{
position: absolute;
top:50px;
left:50px;
z-index:100;
}
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:true,
responsive:{
0:{
items:1
},
600:{
items:1
},
1000:{
items:1
}
}
})
#banner{
position: relative;
}
form{
position: absolute;
top:50px;
left:50px;
z-index:100;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css" />
<div id="banner">
<section id="owl-banner" class="owl-carousel owl-theme">
<div class="item">
<img src="https://blog.bannersnack.com/wp-content/uploads/2018/11/banner-Button-design-770x395.png" alt="banner image 2">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Truhealing-</h5>
<p style="color:#ffffff; font-size:30px;font-family:Titillium Web;line-height:1.6;">Complete Health care <br>Solution for women</p>
</div>
</div>
<div class="item">
<img src="https://blog.bannersnack.com/wp-content/uploads/2018/11/banner-Button-design-770x395.png" alt="banner image 4">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Your health is in <br>your hands</h5>
</div>
</div>
<div class="item">
<img src="https://blog.bannersnack.com/wp-content/uploads/2018/11/banner-Button-design-770x395.png" alt="banner image 3">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Get your hormones <br>working for you</h5>
</div>
</div>
<div class="item">
<img src="https://blog.bannersnack.com/wp-content/uploads/2018/11/banner-Button-design-770x395.png" alt="banner image 4">
<div class="homebannercontent">
<h5 style="color:#ffffff;font-size:60px;font-family:Titillium Web;line-height:1.6;">Address <br>the root cause</h5>
</div>
</div>
</section>
<div class="col-md-6">
<form action="/action_page.php">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>

Changing The Color Of Text In A PHP Modal Form

I have a modal form where I ask people to input information. Up to recently, it has been behaving perfectly now some of the text won't show because the default colour has changed.
The text used to default to black on a white background. I can see the text by highlighting. I have tried changing the text colours but nothing is working. I am baffled as I have not changed this code in months. Not sure why this has changed.
You can see an example in the code I have posted where I have tried to set the text colour to #333333 but there is no change.
The expected colours are a white background with black text.
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Pricing</h4>
</div>
<div class="modal-body pricing">
<div class="row" style="background-color: #333333; color: white;text-align: center;line-height: 35px">
<div class="col-lg-7">Item</div>
<div class="col-lg-2">Qty</div>
<div class="col-lg-3">Price</div>
</div>
<form>
<div class="row itemlabel">
<div class="col-lg-7"><style ="color:DodgerBlue;">Blocks [ Size : 10 pixels X 10 pixels : Min 1 - Max 49]</div>
<div class="col-lg-2"><input class="form-control" type="number" value="1" min="1" max="49" id="blockCount"/> </div>
<div class="col-lg-3"></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">Add Logo</div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addLogo"/> </div>
<div class="col-lg-3" id="addLogoPrice">1.00 USD</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">Add Sticker "Currently FREE to change" <a target="_blank" href="<?php echo get_site_url().'/stickers';?>" class="badgesHelp" data-toggle="tooltip" title="" data-rel="tooltip"> <i class="fa fa-question-circle"></i> </a></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addBadge"/> </div>
<div class="col-lg-3" id="addBadgePrice">0.50 USD</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">Add Link</div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addLink"/> </div>
<div class="col-lg-3" id="addLinkPrice">1.00 USD</div>
</div>
<div class="row" style="background-color: #333333; color: white;text-align: center;line-height: 35px">
<div class="col-lg-12">Listing Duration</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">1 Year</div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration1" /> </div>
<div class="col-lg-3" id="duration1Price">1.00 USD</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">2 Years</div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration2" /> </div>
<div class="col-lg-3" id="duration2Price">2.00 USD</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7">5 Years</div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration3" /> </div>
<div class="col-lg-3" id="duration3Price">5.00 USD</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><h4 style="color:DodgerBlue;"><b>Forever - "BEST VALUE"</b></h4></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration4" /> </div>
<div class="col-lg-3" id="duration4Price">15.00 USD</div>
</div>
</form>
<div class="row" style="font-size: 19px; font-weight: bold; margin-top: 28px;">
<div class="col-lg-9" style="text-align: right">Total</div>
<div class="col-lg-3" style="text-align: left" id="totalAmount">1.00 USD</div>
</div>
</div>
<div class="modal-footer">
<div class="errorMsg" style="text-align:center"></div>
<div class="alert alert-info text-center">You will be able to edit the block and add your story upon successful purchase </div>
<button type="button" class="btn btn-default" onclick="addDataToCart();">Buy Now</button>
</div>
</div>
</div>
</div>
I managed to fix this with some correct formatting. In the past though it worked perfectly, but now it seems you have explicitly define the text colour when before you did not have to.
The only reason I can think of is that the version of wordpress that the web site is built from has updated and maybe the underlying version of php has also updated and now you have to explicitly define the colours.
Here is the updated code:
<!-- Modal -->
<!-- Thi is the code for the Buying Blocks Modal Form -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Pricing</h4>
</div>
<div class="modal-body pricing">
<div class="row" style="background-color: #333333; color: white;text-align: center;line-height: 35px">
<div class="col-lg-7">Item</div>
<div class="col-lg-2">Qty</div>
<div class="col-lg-3">Price</div>
</div>
<form>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>Blocks [ Size : 10 pixels X 10 pixels : Min 1 - Max 49]</b></p></div>
<div class="col-lg-2"><input class="form-control" type="number" value="1" min="1" max="49" id="blockCount"/> </div>
<div class="col-lg-3"></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>Add Logo</b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addLogo"/> </div>
<div class="col-lg-3" id="addLogoPrice"><p style="color:Black;"><b>1.00 USD</b></p></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>Add Sticker "Currently FREE to change" <a target="_blank" href="<?php echo get_site_url().'/stickers';?>" class="badgesHelp" data-toggle="tooltip" title="" data-rel="tooltip"> <i class="fa fa-question-circle"></i> </a></b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addBadge"/> </div>
<div class="col-lg-3" id="addBadgePrice"><p style="color:Black;"><b>0.50 USD</b></p></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>Add Link</b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="addLink"/> </div>
<div class="col-lg-3" id="addLinkPrice"><p style="color:Black;"><b>1.00 USD</div>
</div>
<div class="row" style="background-color: #333333; color: white;text-align: center;line-height: 35px">
<div class="col-lg-12">Listing Duration</div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>1 Year</b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration1" /> </div>
<div class="col-lg-3" id="duration1Price"><p style="color:Black;"><b>1.00 USD</b></p></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>2 Years</b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration2" /> </div>
<div class="col-lg-3" id="duration2Price"><p style="color:Black;"><b>2.00 USD</b></p></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><p style="color:Black;"><b>5 Years</b></p></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration3" /> </div>
<div class="col-lg-3" id="duration3Price"><p style="color:Black;"><b>5.00 USD</b></p></div>
</div>
<div class="row itemlabel">
<div class="col-lg-7"><h4 style="color:DodgerBlue;"><b>Forever - "BEST VALUE"</b></h4></div>
<div class="col-lg-2"><input class="form-control" type="checkbox" value="1" id="duration4" /> </div>
<div class="col-lg-3" id="duration4Price"><p style="color:Black;"><b>15.00 USD</b></p></div>
</div>
</form>
<div class="row" style="color:Black; font-size: 19px; font-weight: bold; margin-top: 28px;">
<div class="col-lg-9" style="text-align: right">Total</div>
<div class="col-lg-3" style="text-align: left" id="totalAmount"><p style="color:Black;"><b>1.00 USD</b></p></div>
</div>
</div>
<div class="modal-footer">
<div class="errorMsg" style="text-align:center"></div>
<div class="alert alert-info text-center">You will be able to edit the block and add your story upon successful purchase </div>
<button type="button" class="btn btn-default" onclick="addDataToCart();">Buy Now</button>
</div>
</div>
</div>
</div>
It could be another reason but not sure. I don't have the knowledge to track such things.

Creating a preview page feature in Laravel 5.1

I am new to Laravel and I am creating content management system as practice to get familiar with the framework. Currently, I am working on the feature for the user to preview the information they have entered for updating the new page they want to create and here is code for the view:
<div ng-controller="PagesController">
<form action="{{url('admin/page/preview')}}" method="post" name="pageForm">
<div class="col-md-9">
<div class="panel-body">
<div class="row">
<div class="form-group">
<label>Title</label>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="text" class="form-control input-md" name="title" ng-model="page.title">
</div>
<!-- <input type="submit" value="Preview"> -->
</div>
<div class="row">
<div class="form-group">
<fieldset style="border: 1px solid #E4E4E4; padding-top: 5px; padding-bottom: 5px;">
<div class="form-group">
<div class="col-md-5">
<label>Add File</label>
<input type="file" name="upload" nv-file-select uploader="updateUploader" value="Select Picture" ng-model="page.upload" >
</div>
<div class="col-md-6">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Progress</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in updateUploader.queue">
<td style="max-width: 170px; word-wrap: break-word;" ng-cloak><strong>#{{ item.file.name}}</strong></td>
<td><div class="col-md-12"><progressbar value="item.progress"></progressbar></div></td>
<td nowrap ng-cloak>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</fieldset>
</div>
</div><br>
<div class="row">
<div class="form-group">
<label>Body</label>
<input type="hidden" name="body" value="#{{page.body}}"/>
<summernote name="body" ng-model="page.body" config="options" height="300"></summernote>
<div ng-messages="pageForm.body.$error" ng-if="pageForm.body.$dirty">
<div ng-message="required">
<span class="error-msgs">Please enter page information</span>
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left">
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="checkbox col-md-12 text-left">
<label><input type="checkbox" value="" ng-model"page.serivice" ng-false-value="0" ng-true-value="1" ><strong>Update page to services</strong></label>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left">
<button type="button" class="btn btn-success" name="update" ng-disabled="pageForm.$invalid" ng-click="update()">Update</button>
<input type="submit" class="btn btn-default btn-md" value="Preview">
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default general-panel publish" style="margin-top: 35px;">
<div class="panel-heading">
<div class="title">Navigation</div>
</div>
<div class="panel-body">
<span class="">
<i></i><strong>Parent pages</strong>
<div class="btn-group">
<select class="form-control" name="publish_period" ng-model="page.parent_nav">
<option value="">No Parent Navigation</option>
<option value="about-us">About Us</option>
<option value="media">Media</option>
<option value="publication">Publication</option>
<option value="law">Law</option>
<option value="legislation">Legislation</option>
<option value="compliance">Compliance</option>
<option value="license">Applying For License</option>
</select>
</div><br><br>
</span>
</div>
</div>
<div class="panel panel-default general-panel general-summary">
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th colspan="3"><h5>Uploaded Documents</h5></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="document in documents">
<td style="max-width: 100px; word-wrap: break-word;">#{{document.file_path}}</td>
<td>
<i class="fa fa-download fa-fw"></i>Download
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div>
Here is the code for the route for previewing the page:
Route::post('page/preview','PagesController#preview');
and the controller method for the preview function:
public function preview(Request $request)
{
return view('admin.pages.preview')->with('title',$request->input('title'))->with('body',$request->input('body'));
}
This works for me, but when I refreshed the preview page it would generate an error saying BadMethodCallException. So I am wondering how can eliminate this from happening? and thanks in advance.

Categories