I have a file, let`s name it dashboard.php, in this file i load a modal window and trough this window i want to submit a form and the form action is also written in this dashboard.php file. is this possible? i am acutally trying it this way, but it s not working:
dashboard:php
<?php $modal_gerade_geschlossen = $_POST['abgespeichert'];
if ($modal_gerade_geschlossen == 1){
$neue_addy = $_POST['neue_addy'];
$benach_ja_nein = $_POST['benach_ja_nein'];
mysql_query("INSERT INTO mitglieder (email,benachrichtigung)VALUES('$neue_addy','$benach_ja_nein')");
}
?>
<div class="modal-body" style="height:194px">
<div>
<form name="losgehts" method="post" action="../dashboard.php">
<div style="float:left">
<input name="neue_addy" style="width:270px" type="text"/>
</div>
</div>
<div>
<select name="benach_ja_nein" >
<option>ja</option>
<option>nein</option>
</select>
</div>
<input type="hidden" name="abgespeichert" value="1"/>
<button type="button" class="btn btn-default" data-dismiss="modal">Schließen</button>
<input type="submit" name="submit" class="btn btn-primary" value="Speichern"/>
</form>
</div>
</div>
Related
I have a problem with my iconpicker: In my form, i want the user to choose an icon. So i added an iconpicker button from FontAwsome. If i put it out of the form, it works. But when i put it into the form, what i just need to do, when i click on it, it submits the form.
I've tried to write "type='button'" but it not works.
Can someone help me and show what's wrong?
Thank you!
<body>
<form method="post" id="form1" action="page_generator.php" enctype="multipart/form-data">
<div id="free_links">
<p >other</p>
<div class="form row" id="free_a_cloner"style="display:none" >
<div class="form-group col-1">
<button name="flnk_0[]" id="ipk" class="btn btn-outline-secondary" data-icon="fas fa-mouse-pointer" role="iconpicker" ></button>
</div>
</div>
</form>
<div class="form row">
<div class="col-sm-10">
<button type="submit" form="form1" class="btn btn-primary">Submit</button>
</div>
</div>
<script>
$("#ipk").iconpicker();
</script>
</body>
Specify that the buttun isn't of type submit by adding type='button':
<button type='button' name="flnk_0[]" id="ipk" class="btn btn-outline-secondary" data-icon="fas fa-mouse-pointer" role="iconpicker" ></button>
you forget to close a div and also try with type="button". sometime it may cause issues. Try the code below and better to create a pen for better understanding or provide head code as well thanks.
<body>
<form method="post" id="form1" action="page_generator.php" enctype="multipart/form-data">
<div id="free_links">
<p >other</p>
<div class="form row" id="free_a_cloner"style="display:none" >
<div class="form-group col-1">
<button type="button" name="flnk_0[]" id="ipk" class="btn btn-outline-secondary" data-icon="fas fa-mouse-pointer" role="iconpicker" ></button>
</div>
</div>
</div>
</form>
<div class="form row">
<div class="col-sm-10">
<button type="submit" form="form1" class="btn btn-primary">Submit</button>
</div>
</div>
<script>
$("#ipk").iconpicker();
</script>
</body>
Add type="button" and check source code on browser because it could be changed by javascript after page rendered and check if there is $("button").onClick.submit like javascript code.
be sure there is only 1 type property i mean not like that:
<button type="button" type="submit">
you can use this code!!
<button type="button" form="form1" class="btn btn-primary">Submit</button>
Route
Route::post('/review/{pId}','RentalController#review');
Controller:
public function review(Request $request,$propId){
$review = new Reviews();
$rpId = rand();
$review->rvid=$rpId;
$review->usid_fk = Auth::user()->uid;
$review->prId_fk = Property::find($propId);
$review->comment = $request->input('comment');
$review->rating = $request->input('rating');
$review->date = Carbon::now();
$review->save();
}
PHP
<form action="/review/{{ $prop->pid}}" method="POST">
{{csrf_field()}}
<div class="modal-body">
<input type="hidden" name="propid" value="{{ $prop->pid }}"/>
<input id="rating" name="rating" class="rating rating-loading" data-show-clear="false" data-min="0" data-max="5" data-step="1" value="0">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Comment</span>
</div>
<textarea name="comment" class="form-control" aria-label="Comment">
</textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
I am getting "page not found", so I don't know whether should I use "put" or "post" method in route as well as in form .
Your replies would be highly appreciated.
I think the problem is from the action in your form.
change your form to
<form action="{{route('review.post',['id'=>$prop->pid])}}" method="POST">
</form>
and change your route to
Route::post('review/{pId}','RentalController#review')->name('review.post');
Inspect the form from browser and make sure csrf token and action url are well formed.
I have a page with 2 pictures (that are in reality radio buttons) and a button "proceed" I can choose one picture or another but when I click on the "proceed" button it doesn't redirect.
Here is the code of my form and my php process page
<body>
<form method="post" action="process.php">
<div class="container">
<div class="row">
<div class="paymentCont">
<div class="headingWrap">
<h3 class="headingTop text-center">Choisissez votre méthode de paiement</h3>
<p class="text-center">Sélectionnez votre méthode puis cliquez sur "Continuer"</p>
</div>
<div class="paymentWrap">
<div class="btn-group paymentBtnGroup btn-group-justified" data-toggle="buttons">
<label class="btn paymentMethod">
<div class="method amex"></div>
<input type="radio" name="paiement" value="paysafecard">
</label>
<label class="btn paymentMethod">
<div class="method vishwa"></div>
<input type="radio" name="paiement" value="paypal">
</label>
</div>
</div>
<div class="footerNavWrap clearfix">
<div class="btn btn-success pull-left btn-fyi"> RETOURNER SUR LE SITE</div>
<div type="submit" class="btn btn-success pull-right btn-fyi" value="Continuer" />Continuer</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
</script>
</form>
</body>
And my php :
<?
if(isset($_POST['paiement']) && ($_POST['paiement']) == "paysafecard"){
header("Location: http://www.example.com/non_company.php");
}
elseif(isset($_POST['paiement']) && ($_POST['paiement']) == "")
{
header("Location: http://www.example.com/company.php");
}
else{
header("Location: http://www.example.com/redirect_to_home.php");
}
?>
I thought typical mistake, not a div tag it is button tag or input tag(type submit) will submit the page
Change the following
<div type="submit" class="btn btn-success pull-right btn-fyi" value="Continuer" />Continuer</div>
Into
<button type="submit" class="btn btn-success pull-right btn-fyi" value="Continuer" />Continuer</button>
In this case you should use:
<input type="submit" value="Continuer" />
Or a tag<button>Continuer</button>
Besides of <div type="submit" class="btn btn-success pull-right btn-fyi" value="Continuer">Continuer</div>
If you want to use a div you'll need to work with JS a make this div to submit
I have next html form:
<form class="form-horizontal" action="frames1.php" method="post">
<div class="form-group">
<label for="uri1" class="control-label">URL:</label>
<div class="controls">
<input type="text" id="uri1" placeholder="www.ejemplo.com">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<input type="submit" class="btn btn-primary" id="submit" value="Visualizar" />
</div>
</form>
I want to pass the value from textbox "uri1" to a php variable.
Thats my frames1.php:
<?php
$uriValue = $_GET["uri1"];
?>
<script>
var uri = '<?php echo $uriValue;?>';
alert(uri);
</script>
But the system shows me "", not the value I put on the textbox in the form just before.
How can pass the value from the textbox to read on the php file?
Thanks!
You are using method as post in form co change this to
<?php
$uriValue = $_POST["uri1"];
?>
<script>
var uri = '<?php echo $uriValue;?>';
alert(uri);
</script>
and also add name attribute to your field. name="uri1"
that is,
<form class="form-horizontal" action="frames1.php" method="post">
<div class="form-group">
<label for="uri1" class="control-label">URL:</label>
<div class="controls">
<input type="text" id="uri1" name="uri1" placeholder="www.ejemplo.com">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<input type="submit" class="btn btn-primary" id="submit" value="Visualizar" />
</div>
</form>
Here is the working link.
You send a form by POST but in your frames1.php file, you try to get the content with $_GET. So what you have to do is just change GETto POST, so it looks like
<?php
$uriValue = $_POST["uri1"];
?>
Also a bigger problem is, that your input doesn't have a name, the parameter can only be referenced by the name, not by the ID. So your input should look like that:
<input type="text" id="uri1" name="uri1" placeholder="www.ejemplo.com">
There are one mistake in HTML as well as PHP code, You have to give name to the input field's. When form is submitted to the server then It will recognize fetch values using HTML Input Field names, and If your posted form in HTML, then you have to use same method to get the values.
Try to replace bellow code with your code:
<form class="form-horizontal" action="frames1.php" method="post">
<div class="form-group">
<label for="uri1" class="control-label">URL:</label>
<div class="controls">
<input type="text" name="uri1" id="uri1" placeholder="www.ejemplo.com">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<input type="submit" class="btn btn-primary" id="submit" value="Visualizar" />
</div>
</form>
Coming to your frames1.php:
<?php
$uriValue = $_POST["uri1"];
?>
<script>
var uri = '<?php echo $uriValue;?>';
alert(uri);
</script>
Let me know still not resolved.
Diff in HTML file is:
<input type="text" name="uri1" id="uri1" placeholder="www.ejemplo.com">
you didn't mention the name, then server will not recognize the element.
In PHP:
Your using POST method but your getting the values using _GET[], both are incompatible methods. So you will not get the values which are submitted by the form
<?php
$uriValue = $_POST["uri1"];
?>
You have set form method="post".
Therefore, after your form gets submitted, the value should be:
$uriValue = $_POST["uri1"];
Not
$uriValue = $_GET["uri1"];
Solutions:
1) Either change your form method method="post" to get your existing code working.
2) Change $uriValue = $_GET["uri1"]; to $uriValue = $_POST["uri1"];
There may be a better way to do this, but I'm trying to create a button group where the left and right buttons are increment/decrement, and the middle button is a disabled button representing the value.
The field properly increments/decrements, but the value isn't getting passed to php.
I do like how the button group looks:
HTML
<form method="POST" action="send_email.php">
<div class="row"">
<div class="col-sm-4 col-xs-4">
<h5><b>Attendees</b></h5>
</div>
<div class="col-sm-8 col-xs-8">
<div class="btn-group">
<input type="button" class="btn btn-default" name="decrease" value="-" onclick="decreaseBtnOnclick('attendees')"/>
<input type="button" class="btn btn-primary" name="attendees" value="0" id="chairs" disabled/>
<input type="button" class="btn btn-default" name="increase" value="+" onclick="increaseBtnOnclick('attendees')"/>
</div>
</div>
</div>
<div class="text-right">
<input type="hidden" name="email" value="contact">
<a href="./index.php">
<button type="submit" class="btn-main">Finish!</button>
</a>
</div>
</form>
Javascript (works fine to change the value in the middle button)
<script>
function increaseBtnOnclick(item) {
document.getElementById(item).value = Number(document.getElementById(item).value) + 1;
}
function decreaseBtnOnclick(item) {
if(document.getElementById(item).value > 0){
document.getElementById(item).value = Number(document.getElementById(item).value) - 1;
}
}
PHP (works fine for other types of inputs, e.g., text)
<?php
if(isset($_POST['email'])) {
$attendees = $_POST['attendees']; // required
echo "Attendees: ".$attendees;
}
?>
Try adding a hidden input then add the value of your disabled button to it with JS.
JS
function increaseBtnOnclick(item) {
var newValue = Number(document.getElementById(item).value) + 1;
document.getElementById(item).value = newValue;
document.getElementById("hidden_input").value = newValue;
}
function decreaseBtnOnclick(item) {
if(document.getElementById(item).value > 0){
var newValue = Number(document.getElementById(item).value) - 1;
document.getElementById(item).value = newValue;
document.getElementById("hidden_input").value = newValue;
}
}
HTML:
<form method="POST" action="send_email.php">
<div class="row"">
<div class="col-sm-4 col-xs-4">
<h5><b>Attendees</b></h5>
</div>
<div class="col-sm-8 col-xs-8">
<div class="btn-group">
<input type="button" class="btn btn-default" name="decrease" value="-" onclick="decreaseBtnOnclick('attendees')"/>
<input type="button" class="btn btn-primary" name="attendees" value="0" id="chairs" disabled/>
<input type="button" class="btn btn-default" name="increase" value="+" onclick="increaseBtnOnclick('attendees')"/>
<input type="hidden" name="hiddenvalue" id="hidden_input" value="0">
</div>
</div>
</div>
<div class="text-right">
<input type="hidden" name="email" value="contact">
<a href="./index.php">
<button type="submit" class="btn-main">Finish!</button>
</a>
</div>
</form>
PHP:
<?php
if(isset($_POST['email'])) {
$attendees = $_POST['hiddenvalue']; // required
echo "Attendees: ".$attendees;
}
?>
You could switch to a regular input field with button addons.
Disabled input fields do not get posted, however you can set it to readonly.
Please have a look at this thread,
Disabled form inputs do not appear in the request
You could use a hidden input field:
<input type="hidden" id="h_attendees" name="h_attendees" value="0"/>
In your increaseBtnOnclick and decreaseBtnOnclick you could set the value of the hidden field.
function increaseBtnOnclick(item) {
document.getElementById(item).value = Number(document.getElementById(item).value) + 1;
document.getElementById("h_attendees").value = document.getElementById(item).value;
}
function decreaseBtnOnclick(item) {
if(document.getElementById(item).value > 0){
document.getElementById(item).value = Number(document.getElementById(item).value) - 1;
document.getElementById("h_attendees").value = document.getElementById(item).value;
}
}
And access it in PHP
$_POST['h_attendees'];