Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
At first I write a simple hotel.php
<div role="main" class="ui-content">
<?php
$info = $_GET['type'];//works well $info get num= 1;
?>
<h3 class="ui-bar ui-bar-a ui-corner-all">order</h3>
<div class="ui-body ui-body-a ui-corner-all">
<form action="sendmail.php" method="get">
<ul data-role="listview" data-inset="true">
<li class="ui-field-contain">
<label for="name">name</label>
<input type="text" name="name" id="name" vlaue="" data-clear-btn="true">
</li>
<li class="ui-field-contain">
<label for="phone">phone</label>
<input type="text" name="phone" id="name2" vlaue="" data-clear-btn="true">
</li>
<li class="ui-field-contain">
<input class="invisible" type="text" name="room_info" value="<?php $_GET['type'];?>">
<label for="slider-2">num</label>
<input type="range" name="slider-2" id="slider-2" data-mini="true" data-highlight="true" min="1" max="6" value="4" data-clear-btn="true">
</li>
<li class="ui-field-contain">
<label for="arrive-time">a_time</label>
<input type="datetime-local" name="arrive-time" id="arrive-time" value="" data-clear-btn="true">
</li>
<li class="ui-field-contain">
<label for="leave-time">b_time</label>
<input type="datetime-local" name="leave-time" id="arrive-time" value="" data-clear-btn="true">
</li>
<li class="ui-body ui-body-b">
<fieldset class="ui-grid-a">
<div class="ui-block-a"><button type="reset" class="ui-btn ui-corner-all ui-btn-a">reset</div>
<div class="ui-block-b"><button type="submit" class="ui-btn ui-corner-all ui-btn-a" data-ajax="false">sbumit</div>
<fieldset>
</li>
</ul>
</form><!--end form-->
</div>
</div>
It's strange that $info = $_GET['type']; works well and the $info get the value correctly.
but when I click the submit button.
in target webpage sendmail.php
$name=$_GET['name'];
$phone=$_GET['phone'];
$roominfo=$_GET['room_info'];
$num=$_GET['slider-2'];
$a_time=$_GET['arrive-time'];
$b_time=$_GET['leave-time'];
all get the right information except the roominfo is null.
what's the problem with this">I try this">but steel not work
Try to echo:
<input class="invisible" type="text" name="room_info" value="<?php $_GET['type'];?>">
to
<input class="invisible" type="text" name="room_info" value="<?php echo $_GET['type'];?>">
EDIT
OP seems to want this element hidden so that's why there is invisible class. Well, you don't need to create a class for this case. You can use hidden.
<input type="hidden" name="room_info" value="<?php echo $_GET['type'];?>">
Use echo
<input class="invisible" type="text" name="room_info" value="<?php echo $_GET['type'];?>">
Related
am trying to make a "Add your recipe" page in my website.. i have tried this form and it shows perfectly.. but how do i post the recipe below the form after clicking submit button according to the recipe format?
<center>
<form method="post">
<div class='wrapperr'>
<div class='wrapper'>
<div class='container'>
<div class='top'>
<div class='logo'></div>
<div class='gray close'></div>
</div>
<div class='content'>
<ul class='section'>
<li class='header'></li>
<li class='item right-label'>
<label for="title">Title</label>
<input type="text" placeholder='eg. Chocolate Chip Cookies' id="title" class='shorter' />
<div class='picture-container'>
<div class='picture'></div>
</div>
</li>
<li class='item right-label'>
<label for="author">Author</label>
<input type="text" placeholder='eg. Julia Child (optional)' id="author" class='shorter' />
</li>
<li class='item right-label'>
<label for="adapted">Adapted</label>
<input type="text" placeholder='eg. The Joy of Cooking (optional)' id="adapted" class='shorter' />
</li>
<li class='item right-label'>
<label for="adapted-link">Adapt Link</label>
<input type="text" placeholder=' (optional)' id="adapted-link" class='shorter' />
<input type="button" class="button green box-shadow" value="Select Image" id="picture" />
</li>
<li class='item spaced right-label'>
<label for="summary" id="summary-label">Description</label>
<textarea placeholder='eg. A delicious drop cookie (optional)' id="summary"></textarea>
</li>
<li class='item right-label'>
<label for="prep-time">Prep Time</label><input type="text" placeholder="HH:MM (optional)" id="prep-time" class="time" />
<label for="cook-time">Cook Time</label><input type="text" placeholder="HH:MM (optional)" id="cook-time" class="time" />
<label for="total-time">Total Time</label><input type="text" placeholder="HH:MM (optional)" id="total-time" class="time" />
</li>
<li class='item right-label'>
<label for="servings">Serves</label><input type="text" placeholder="Amount (optional)" id="servings" class="amount" />
<label for="yields">Yields</label><input type="text" placeholder="Amount (optional)" id="yields" class="amount" />
</li>
<li class='header new'></li>
<li class='item'>
<label for="ingredients">Ingredients</label>
<textarea placeholder="One ingredient per line, include subheaders by ending with a colon (eg. For the cake:)" id="ingredients" class='larger'></textarea>
</li>
<li class='item'>
<label for="directions">Directions</label>
<textarea placeholder="One direction per line, include subheaders by ending with a colon (eg. For the cake:)" id="directions" class='larger'></textarea>
</li>
<li class='item'>
<label for="notes">Notes</label>
<textarea placeholder="One note per line, include subheaders by ending with a colon (eg. Great tip:) (optional)" id="notes" class='larger'></textarea>
</li>
<li class='header new error-list' style="display: none"></li>
<li class='new error-data' style="display: none">
<ul class='error-ul'>
<li class='error-title' style="display: none">Please enter a title for the recipe.</li>
<li class='error-adapted-link' style="display: none">Please enter a valid url.</li>
<li class='error-prep-time' style="display: none">Please enter a prep time using HH:MM such as <b>1:15</b> for an hour and fifteen minutes or <b>25</b> for 25 minutes.</li>
<li class='error-cook-time' style="display: none">Please enter a cook time using HH:MM such as <b>1:15</b> for an hour and fifteen minutes or <b>25</b> for 25 minutes.</li>
<li class='error-total-time' style="display: none">Please enter a total time using HH:MM such as <b>1:15</b> for an hour and fifteen minutes or <b>25</b> for 25 minutes.</li>
<li class='error-servings' style="display: none">Please enter a number for the serves amount such as <b>4</b> for a recipe that makes 4 servings.</li>
<li class='error-yields' style="display: none">Please enter a number for the yields amount such as <b>18</b> for a recipe that makes 18 cookies.</li>
<li class='error-ingredients' style="display: none">Please enter some ingredients for your recipe.</li>
</ul>
</li>
<li class='new center'>
<input type="button" class='button green standard-button box-shadow' value='Save' id="save" />
<input type="button" class='button white standard-button box-shadow' value='Cancel' id="cancel" />
<div class='working'>
<div class='working-image'></div>
<div class='working-text'>Saving Recipe</div>
</div>
</li>
</ul>
</div>
</div>
</div></center>`
Here is the link to the comments box made using HTML and JavaScrit. It doesn't work on the submit button but serves the purpose.
HTML:
<form>
<textarea id="comment" placeholder="Say something..." /></textarea><br>
Post comment!
</form>
<div id="comments">
</div>
JavaScript:
window.postComment=function()
{
var div = document.getElementById("comments");
div.innerHTML = div.innerHTML +"<br>"+ document.getElementById("comment").value;
}
Fiddle here.
Create a php file called 'Config.php'
class Config {
public static function get($item){
if(isset($_POST[$item])){
return $_POST[$item];
} else if(isset($_GET[$item])) {
return $_GET[$item];
}
return '';
}
}
then add a require_once 'Config.php' to your page with the form
if(isset($_POST['submit']){ // if user submits form
echo Config::get('comments');
}
The function will check the form method, and return the $_POST or $_GET value. We then check if the user has submitted the form. Once they do, it will get the value and echo it to the page.
I wrote a code and i used Boostrap to make 2 dropdown : Sign In and Sign Up. After i complete input fields , informations aren't send ... and submit button redirect me to index.php?username="What is in username field"&password="Password typed" .
I wanna send data to informations index.php?tab=SignIn... What could be wrong ?
<ul class="nav navbar-nav nav pull-right">
<li class="animated dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-lock fa-2x"></i><br /> Register <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<?php
#$_SESSION['username2'] = $_POST['username'];
#$_SESSION['email'] = $_POST['email'];
#$_SESSION['password'] = $_POST['password'];
?>
<form class="form" id="formLogin" action="index.php?tab=SignUp">
<li><div class="form-group">
<input type="text" name="username" id="username" class="form-control" placeholder="Username" value="<?= $_SESSION['username2'] ?>" required/>
</div></li>
<li><div class="form-group">
<input type="email" name="email" id="email" class="form-control" placeholder="E-Mail Address" value="<?= $_SESSION['email'] ?>" required/>
</div></li>
<li><div class="form-group">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" value="<?= $_SESSION['password'] ?>" required/>
</div></li>
<li class="divider"></li>
<input type="submit" name="register" class="btn btn-success" value="Register" tabindex="7">
</form>
</ul>
</li>
</ul>
replace this
<form class="form" id="formLogin" action="index.php?tab=SignUp">
with this
<form class="form" id="formLogin" action="index.php" method="post">
<input type="hidden" name="tab" value="SingUp" />
and in your index.php get tab parameter by $_POST['tab']
change
<form class="form" id="formLogin" action="index.php?tab=SignUp">
to
<form class="form" id="formLogin" action="index.php?tab=SignUp" method="post">
Nope. Just call index.php each time. No suffixes to the url ever. If you want a special value, then create a hidden element in the form, with the value set so the second time the user hits index.html, the value will populate...
<?php
#$_SESSION['username2'] = $_POST['username'];
#$_SESSION['tab'] = $_POST['tab']; // set in the original form in a hidden field.
#$_SESSION['email'] = $_POST['email'];
#$_SESSION['password'] = $_POST['password'];
?>
Somewhere along the line do a test if ($_POST['tab'] == "SignUp") then do whatever. If $_POST['tab'] isnt = SignUp, then you know its the first time to that page....
Keep it very simple. Less is more! (oops.. I'm a duplicate of the posting by Gabriele Pieretti) I'm upvoting GP! thx.
I'm using smarty and PHP for my website. Following is my form code from smarty template.
<form id="manage_reply_enquiry" name="manage_reply_enquiry" method="post" action="{$control_url}modules/enquiries/reply_to_enquiry.php" enctype="multipart/form-data">
<ul>
<li>
<label>{'To Name'|signal_on_error:$error_msg:'contact_name'} :</label>
<div class="form-element">
<input type="text" name="contact_full_name" id="contact_full_name" value="{$data.contact_full_name|capitalize}" class="">
</div>
</li>
<li>
<label>{'To Email'|signal_on_error:$error_msg:'email'} :</label>
<div class="form-element">
<input type="text" name="contact_email_id" id="contact_email_id" value="{$data.contact_email_id}" class="">
</div>
</li>
<li>
<label>{'Reply'|signal_on_error:$error_msg:'reply'} :</label>
<div class="form-element">
<textarea name="reply" id="reply" cols="60" rows="12">{$data.reply}</textarea>
</div>
</li>
<li>
<label>{'Upload File'|signal_on_error:$error_msg:'reply_file_name'} :</label>
<div class="form-element">
<p class=""><input type="file" id="reply_file_name" name="reply_file_name" /></p>
<div class="input-info"> <span class="required">Note* (Image size should be less then 1 mb and alowed format types are CSV, XLS)</span></div>
</div>
</li>
<input type="hidden" name="contact_id" value="{$data.contact_id}" />
<input type="hidden" name="from_date" value="{$from_date}" />
<input type="hidden" name="to_date" value="{$to_date}" />
<input type="hidden" name="op" value="{$op}" />
<li>
<label></label>
<div class="form-element">
<input type="submit" name="submit" id="submit" class="c-btn" value="Send">
<input type="button" name="cancel" id="cancel" class="c-btn" value="Cancel" onclick="javascript:window.location.href='{$control_url}modules/enquiries/view_contact_us.php?page={$page}&from_date={$from_date}&to_date={$to_date}'">
</div>
</li>
</ul>
</form>
If I print the Posted data in the reply_to_enquiry.php file, I'm getting following data:
Array
(
[contact_full_name] => ABCD
[contact_email_id] => abcd#gmail.com
[reply] => How are you now?
[contact_id] => 59
[from_date] => 10/09/2000
[to_date] => 10/09/2013
[op] => view
[submit] => Send
)
Can you tell me why I'm not able to get the value from file control named reply_file_name from the form? I couldn't get why this is happening. Can anyone help me in this regard? Thanks in advance.
When you do an upload in PHP, the informations relative to the uploaded file are in the $_FILES variable.
Here a minimal upload script. (don't use it in production environment)
<?php
if(isset($_FILES['reply_file_name'])){
$target = "some/path/".basename($_FILES['reply_file_name']['name']) ;
print_r($_FILES);
if(move_uploaded_file($_FILES['reply_file_name']['tmp_name'],$target)) echo "OK!";//$chmod o+rw some/path
}
?>
I'm using PHP, Smarty and jQuery for my website. There is a functionality of showing and hiding an element on a form. The HTML as well as code from jQuery function is as below:
HTML Code:
<div class="c-mega-accord">
<ol class="fnAccordion">
<li>
<a class="fnTrigger" href="#">Practice Sheet Basic Details <span></span></a>
<div class="fnAccContent">
<div class="c-grad-box">
<div class="form-wrapper">
{if $error_msg}<div class="error-info">{$error_msg.error_msgs}</div>{/if}
<form name="manage_practice_sheet" id="manage_practice_sheet" action="practice_sheet.php" method="post">
<input type="hidden" name="op" id="op" value="{$op}" />
<input type="hidden" name="sheet_type" id="sheet_type" value="{$sheet_type}" />
<input type="hidden" name="form_submitted" id="form_submitted" value="yes" />
<input type="hidden" name="practice_sheet_id" id="practice_sheet_id" value="{$practice_sheet_id}" />
<input type="hidden" name="hidden_practice_sheet_category_id" id="hidden_practice_sheet_category_id" value="{$practice_sheet_category_id}" />
<input type="hidden" name="practice_sheet_id" id="practice_sheet_id" value="{$practice_sheet_id}" />
<p class="form-info fl-right">* Mandatory fields</p>
<ul>
<li>
<label>{'Category'|signal_on_error:$error_msg:'practice_sheet_category_id'}<span class="reqd">*</span></label>
<div class="form-element">
<select name="practice_sheet_category_id" id="practice_sheet_category_id" <!--onChange="get_subcategory_by_category('{$control_url}modules/category/manage_category.php', this.value, 'get_subcategory_by_category', '#practice_sheet_sub_category_id');"--> >
<option value="">Select</option>
{if $all_parent_categories}
{foreach from=$all_parent_categories item="parent_category"}
<option value="{$parent_category.category_id}" {if $data.practice_sheet_category_id==$parent_category.category_id || $practice_sheet_category_id==$parent_category.category_id} selected="selected"{/if}>{$parent_category.category_name}</option>
{/foreach}
{/if}
</select>
</div>
</li>
<li>
<label>{'Practice Sheet Name'|signal_on_error:$error_msg:'practice_sheet_name'}<span class="reqd">*</span></label>
<div class="form-element">
<input class="" type="text" name="practice_sheet_name" id="practice_sheet_name" value="{$data.practice_sheet_name}" maxlength="50">
</div>
</li>
<li>
<label>Display Date</label>
<div class="form-element">
<input type="text" class="cal fl-left" id="frmDate" name="frmDate" value="{if $data.practice_sheet_display_date !='0' && $data.practice_sheet_display_date !=''}{$data.practice_sheet_display_date}{/if}">
</div>
</li>
<li>
<label>Practice Sheet For</label>
<div class="form-element">
<input class="" type="text" name="practice_sheet_for" id="practice_sheet_for" value="{$data.practice_sheet_for}" maxlength="50">
</div>
</li>
<li>
<label></label>
<div class="form-element">
<!--<input type="submit" value="{$submit_value}" class="c-btn" id="saveAddMore" name="submit">
<input type="button" value="{$cancel_value}" class="c-gray-btn" id="done" name="done" onclick="javascript:window.location.href='{$control_url}modules/practice_sheet/practice_sheet.php?op={$query_string}'"><br/>-->
<span class="c-btn c-continus-btn"><input type="button" name="continus" id="continus" value="Continue" id="" name=""></span>
<span class="c-gray-btn c-cancel-btn"><input type="button" value="Cancel" id="" name=""></span>
</div>
</li>
</ul>
</form>
</div>
</div>
</div>
</li>
<li>
<a class="fnTrigger" href="#">Select Category <span></span></a>
<div class="fnAccContent">
<div class="c-grad-box">
</div>
</div>
</li>
</ol>
</div>
jQUery Code:
function accordion(){
var li = $(".fnAccordion > li");
li.eq(0).addClass("active");
li.children('.fnAccContent').not(':first').hide();
$(".fnAccordion .fnTrigger").click(function(e){
e.preventDefault();
var numLi = $(this).parent('li').siblings();
if(numLi.length > 0){
$(this).parent('li').siblings().removeClass("active");
var curState = $(this).parent().find(".fnAccContent").css("display");
if(curState == "none"){
$(".fnAccContent").slideUp();
$(this).parent().addClass("active");
$(this).parent().find(".fnAccContent").slideDown();
}
}else{
$(this).parent('li').toggleClass("active");
$(this).parent().find(".fnAccContent").slideToggle();
}
})
}
$(document).ready(function(){
accordion();
})
Now the functionality of hide/show is working fine when I click on following two elements:
<a class="fnTrigger" href="#">Practice Sheet Basic Details <span></span></a>
<a class="fnTrigger" href="#">Select Category <span></span></a>
Actually I want to make this functionality work on Continue button(following is the HTML code snippet for it):
<input type="button" name="continus" id="continus" value="Continue" id="" name="">
I tried to make it work on Continue button by applying the class fnTrigger but it didn't work. Can you help me in this regard? Thanks in advance.
If you want the function to be triggered when both the classes are present,
you use
$(".fnAccordion .fnTrigger").click(function(){
//Your code here
});
If you want the function to get triggered when element of either class is clicked, use a "," to separate the classes.
$(".fnAccordion, .fnTrigger").click(function(){
//Your code here
});
Your check only checks for the fnTrigger class INSIDE an element with the class fnAccordion
$(".fnAccordion .fnTrigger").click(function(e){});
Is your button inside the element with the class fnAccordion?
UGH.
Hi.
I have a form. I'd like to know how/if I could submit this form to an iFrame that has the page that will handle the file upload/naming.
If I try even something simple like post an input/text to the form, nothing happens (the handler is set to echo the $_POST). I have tried setting the iframe name/id et. al. and setting the form target to the respective iframe name/id. When I hit submit, the iframe just sits there like a dummy. WTF am I doing wrong?
Thx.
<form action="/clients/testAddTrans/<?=$clientID?>" id="reportEdit" class="EditName" method="POST" target="transFrame">
<div class="inputDiv">
<span class="inputLabel">Description:</span>
<span class="textInput">
<input type="text" id="transDesc" name="transDesc" value="" size="40" class=""/>
</span>
</div>
<div class="inputDiv">
<span class="inputLabel">Date:</span>
<span class="textInput">
<input type="text" id="date" name="transDate" value="" size="40" class=""/>
</span>
</div>
<div class="inputDiv">
<span class="inputLabel">File:</span>
<span class="textInput">
<input type="file" id="file" name="transFile" value="" size="40" class=""/>
</span>
</div>
<input name="name_id" type="hidden" value="<?=$itemid?>" />
<input type="submit" value="Submit" name="submit"/>
<input type="button" class="secondaryAction" onclick="hideOverDiv()" value="Close"/>
<div id="overDivNotice" class="overDivNotice" style="display:none"></div>
<iframe action="/clients/testAddTrans/<?=$clid?>" id="transFrame" name="transFrame" style=""></iframe>
</form>
Generated html via firebug:
<div class="content" id="overDivContent"><div class="inputDivContainer">
<fieldset class="inputOverDiv" id="tfa_Names">
<legend><b>Add Transmittal:</b></legend>
<div class="data"><form target="transFrame" method="POST" class="EditName" id="reportEdit" action="/clients/testAddTrans/fsdf1556"><div class="inputDiv"><span class="inputLabel">Description:</span><span class="textInput"><input type="text" class="" size="40" value="" name="transDesc" id="transDesc"/></span></div><div class="inputDiv"><span class="inputLabel">Date:</span><span class="textInput"><input type="text" class="" size="40" value="" name="transDate" id="date"/></span></div><div class="inputDiv"><span class="inputLabel">File:</span><span class="textInput"><input type="file" class="" size="40" value="" name="transFile" id="file"/></span></div><input type="hidden" value="121" name="name_id"/>
</form><br/>
<div align="center" class="actions" id="overDivActions">
<input type="submit" name="submit" value="Submit"/>
<input type="button" value="Close" onclick="hideOverDiv()" class="secondaryAction"/>
</div>
<div style="display: none;" class="overDivNotice" id="overDivNotice">
</div></div>
<iframe style="" name="transFrame" id="transFrame">tyh</iframe>
</fieldset>
</div></div>
I don't know why it is putting the </form> tag where it is.. It is supposed to be after the iframe, but whatever. Does that even matter? Is the iframe supposed to be inside the form?
Nice, I was wrong.. I found the problem.
First use html for write html;
With the code below works:
for 'testSubmitiFrame.html':
<form target="transFrame" method="POST" class="EditName" id="reportEdit" action="testSubmitiFrame.php">
<div class="content" id="overDivContent">
<div class="inputDivContainer">
<fieldset class="inputOverDiv" id="tfa_Names">
<legend><b>Add Transmittal:</b></legend>
<div class="data">
<div class="inputDiv">
<span class="inputLabel">Description:</span>
<span class="textInput"><input type="text" class="" size="40" value="" name="transDesc" id="transDesc"/></span>
</div>
<div class="inputDiv">
<span class="inputLabel">Date:</span>
<span class="textInput"><input type="text" class="" size="40" value="" name="transDate" id="date"/></span>
</div>
<div class="inputDiv">
<span class="inputLabel">File:</span>
<span class="textInput"><input type="file" class="" size="40" value="" name="transFile" id="file"/></span>
</div>
<input type="hidden" value="121" name="name_id"/>
<br/>
<div align="center" class="actions" id="overDivActions">
<input type="submit" name="submit" value="Submit"/>
<input type="button" value="Close" onclick="hideOverDiv()" class="secondaryAction"/>
</div>
<div style="display: none;" class="overDivNotice" id="overDivNotice"></div>
</div>
</fieldset>
</div>
</div>
</form>
<iframe style="" name="transFrame" id="transFrame">tyh</iframe>
for 'testSubmitiFrame.php':
<?php
var_dump($_POST);
?>
Your problem is html syntax. This works.
Apparently, a div or stupid fieldset tag being out of place was preventing the thing from working. I really gotta start checking my code before bothering you nice people.
Thanks anyway.
Your logic appears valid, can you setup a test page?
This page will do what you want, so you may want to look through it and see what may be different from what you are already doing:
http://www.anyexample.com/programming/php/php_ajax_example__asynchronous_file_upload.xml
Is the action in the html the php file that will do the processing?
I think it's because of these two lines:
echo "</div>";
echo "</div><br>
You're closing <div> with no opening tags. This is making Firefox close the <form> early - your submit button isn't inside your form, which is why it's not working.
The position of the iframe inside or outside the form doesn't matter - just make sure the rest of the HTML is valid and it should work.