I cant transfer html data with form above 3 pages - php

I have 3 pages.
a1.php : add record
a2.php : do sth
a3.php : record them database
But problem is occured, transfering "html data" from a2.php to a3.php.
EXAMPLE: a record which I try to record to a1.php is that :
<form name="form1" type="post" action="sayfa_1.php">
<input type='submit' value=' gidiyoruz' >
<input type='submit' value=' gidiyoruz' >
</form>
a1.php --> a2.php --> a3. php
On a2.php, there i no problem. But then. On a3.php when I show coming data, I SEE TWO BUTTON, NO HTML CODES which is above.
pages is below.
thanks.
a1.php
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">
//<![CDATA[
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
//]]>
</script>
<form name="form1" type="post" action="a2.php">
<textarea rows="20" cols="90" id="anlam" name="anlam" style="overflow:auto;" > </textarea>
<input type="submit" />
</form>
a2.php
<?php
$anlam=$_GET["anlam"];
echo $anlam;
?>
<?php echo "<form name='fm' id='fm' action='a3.php' method='get'>"; ?>
<textarea rows="2" cols="50" name="anlam" style="visibility:hidden;" /> <?php echo $anlam; ?> </textarea>
<input type="submit" />
</form>
a3.php
<?php
$anlam=$_GET["anlam"];
echo nl2br($anlam);
Pace images are above. error: a3.php (instead code, there are two button)

so you want the page to send your data from one to another when you click submit button!!
Use if condition with isset.
if(isset($_POST['name_of_submit_button']))
{
// your code of next page
}
n similarly continue with another page by giving another name to you submit button and applying the same condition!!

Try using
method="post"
for your form. You could also just use an
<input type="hidden" name="anlam" value="<?php echo $anlam; ?>"/>
to transport your variable content to the last page. Are you sure, that the hidden textarea/input contains the correct value? Check the source code in your browser for this step.

Related

need help to hide url id while editing a record

i'm displaying list of countries information from database to jquery datatable
with edit and delete options.here while editing i'm getting following url
http://localhost/fad/admin/edit_country.php?id=5
i want to hide id number and my url format should be
http://localhost/fad/admin/edit_country/
any one help me to solve this...
Use form method as POST instead of GET
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
The php file which processes your data should be like this.
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
For your case use this code.
<form id="myform<?php echo $country['COUNTRY_ID'];?>" method="post" action="edit_country.php">
<input type="hidden" name="id" value="<?php echo $country['COUNTRY_ID'];?>"/>
<a onclick="document.getElementById('myform<?php echo $country['COUNTRY_ID'];?>').submit();" class="tablectrl_small bDefault tipS" title="Edit">click here</a>
</form>
Read about mod_rewrite and try to send params as POST.

Form submit is not sending any POST data

On my web page, when I press the "Add Customer" link, the following happens:
the onclick handler is called, which
sets values into the forms two text fields
displays an alert (at this point you can see the new values in the text fields on the screen)
calls the form's submit button (Note: the form submits back to it's own PHP file)
The same php file is called, but there are no POST values received
I've verified this with
the code in the first line that counts the values in $_POST then displays later
using fiddler to look at the request sent to the page
I've done this type of thing numerous times before with no problems. I've copied this code to two different web servers (linux, apache) with the same result. It's probably a minor problem but I can't find it.
I've stripped out a whole bunch of code to get down to this little bit, but haven't figured out why no POST values are being sent.
You can see a working copy of this at http://www.daleann.org/dla.php. The only thing need besides the code below is /js/jquery.min.js.
Thanks for your help.
<?php
$pc=count($_POST)."<br />".date("H:i:s");
?>
<html>
<head>
<script src="/js/jquery.min.js" /></script>
<script type="text/javascript">
$(document).ready(function() {
alert("inside docReady");
$(document).on('click', "a.menuBillingOwner", function() {
$("#selectedBillingOwner").val("11");
$("#lastCustomNavSelected").val("selectedBillingOwner");
alert("selectedBillingOwner = "+document.forms['formBillingOwner'].elements['selectedBillingOwner'].value);
document.forms['formBillingOwner'].submit();
});
});
</script>
</head>
<body>
<ul id="menuBillingOwner">
<li><a href='#' id='menuBillingOwnerAdd' class='menuBillingOwner'>Add Customer</a></li>
</ul>
<?php
$lastCustomNavSelected = $selectedBillingOwner = "";
if (count($_POST) > 0 && isset($_POST['selectedBillingOwner'])) {
$lastCustomNavSelected = "selectedBillingOwner";
$selectedBillingOwner = $_POST['selectedBillingOwner'];
}
?>
<?php echo "pc = ".$pc."<br />\n"; ?>
<form name="formBillingOwner" id="formBillingOwner" method="POST" action="/dla.php">
<input type="text" id="lastCustomNavSelected" value="<?php echo $lastCustomNavSelected; ?>" />
<input type="text" id="selectedBillingOwner" value="<?php echo $selectedBillingOwner; ?>" />
</form>
</body>
</html>
Simple, because your form fields don't have name attributes, see below
<form name="formBillingOwner" id="formBillingOwner" method="POST" action="/dla.php">
<input type="text" id="lastCustomNavSelected" value="<?php echo $lastCustomNavSelected; ?>" />
<input type="text" id="selectedBillingOwner" value="<?php echo $selectedBillingOwner; ?>" />
</form>
Add names to them, for example:
<form name="formBillingOwner" id="formBillingOwner" method="POST" action="/dla.php">
<input type="text" id="lastCustomNavSelected" name="lastCustomNavSelected" value="<?php echo $lastCustomNavSelected; ?>" />
<input type="text" id="selectedBillingOwner" name="selectedBillingOwner" value="<?php echo $selectedBillingOwner; ?>" />
</form>
Note: Probably your jQuery assignments need to be fixed too but if that was the only issue then atleast a wrong value should have been POSTed to PHP, hence that is not the issue.
Delete these 2 lines of your jQuery.
$("#selectedBillingOwner").val("11");
$("#lastCustomNavSelected").val("selectedBillingOwner");
because that will change the value of textfield before your submit the form

How to call php variable input text from another Php page

My question is how do I call input value of user selected which has show by php code from another php.
Normal simple way we get the input this way
$calendar_id_val = $_GET['calendar_id'];
and now it is not working:
For example Show.php, I have one form which show the values from Database and show the result with php variable with While Loop.
<input name="calendar_id" value="<?php echo $calendar_id;?>">
and when user is submit that form I will carry these user selected value and perform insert.php
While you are doing echo in the input use echo $calendar_id_val
You should use form like,
<form action="insert.php" method="get">
<input type="text" name="calendar_id" value="<?php echo $calendar_id;?>"/>
<input type="submit" name="submit_id" value="Insert"/>
</form>
Insert.php
echo $calendar_id_val = $_GET['calendar_id'];
Does this answer your question?
<form action="insert.php" method="GET">
<input name="calendar_id" value="<?php echo $calendar_id;?>">
</form>
If you want to redirect the user back to show.php, add this to the end of your insert.php script
header('Location: show.php');
exit();
I suggest $_POST var like this:
<form action="insert.php" method="POST">
<input type="text" name="calendar_id" value="<?php echo $calendar_id;?>" />
<input type="submit" name="submit" value="Submit" />
</form>
insert.php file:
echo $calendar_id = $_POST['calendar_id'];

Getting a php file in an iframe

I have two files one is index.php which contains a form which gets submitted to abc.php.Now the problem is have a frame in index.php where in i want to display the datas that i got after submitting the form to abc.php.I tried but m not able to it.Hope i hav mentioned all the thngs required. Any suggestion will be appreciated.
Set your form's target (phpfiddle demo):
<?php
if(!empty($_POST['submit_to_frame']))
{
echo htmlspecialchars($_POST['the_data']);
}
else
{
?>
<iframe id="the_frame" name="the_frame"></iframe>
<form method="POST" target="the_frame">
<input type="hidden" name="submit_to_frame" value="true" />
<input type="text" name="the_data"/>
<input type="submit" value="OK">
</form>
<?php
}
?>

Retrieving already assigned text box value dynamically in javascript

I have a form in PHP which looks like this:
<?php
$txtVal1 = "value1";
?>
<script type="text/javascript">
function post_data(){
alert(document.getElementById("text1").value);
}
</script>
<form method="post" action="">
<input type="text" value="<?php echo $txtVal1;?>" id="text1"/>
<input type="button" value="Post" onclick="post_data()"/>
</form>
My question is whenever I click "Post" button I get an alert message as "value1". This is fine. But now if I change the text box value to something else from the UI I still get the old value. Is there any solution to get the changed value?
Try this. this works. check if your php value is putting value correctly or not
<script type="text/javascript">
function post_data(){
alert(document.getElementById("text1").value);
}
</script>
<form method="post" action="">
<input type="text" id="text1"/>
<input type="button" value="Post" onclick="post_data()"/>
</form>
<pre>
<?php <br/>
$txtVal1 = "value1";<>
?>
<script type="text/javascript">
function post_data(){
alert(document.getElementById("text1").value);
}
function test(val){
document.getElementById("text1").value = val;
}
</script>
<form method="post" action="">
<input type="text1" value="<?php echo $txtVal1;?>" onChange="test(this.value)" id="text1"/>
<input type="button" value="Post" onclick="post_data()"/>
</form>
Try this jQuery fiddle
It may be overkill but it works. StackOverflow doesn't like links to jsfiddle?
$("#submit").click(function(){
alert($("#text1").val());
});
Your page when ever load the first php value assign and after that run all value that is the problem for that. You change to assign value for the above one $txtVal1 = "value1";

Categories