4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by vwdmt
0

i actually never thought of that. that's a pretty good idea for a work around and I may end up using that, but are there any other ways that are a little more conventional?

0

Create a form with a submit button, Inside form tag define attributes method="post" action="filename.php".

Then within the form whatever tag you define with name attribute will passed to filename.php while on submit.

In filename.php use:

$id=$_POST;
echo $id;

0

You can do it by using cookies and javascript

<?php
setcookie('id','125');
echo "<a href=updateInfoForm.html>a1</a>";
?>

updateInfoForm.html:

<script type="text/javascript">

alert(getCookie("id"));


function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}

</script>

0

thanks guys for all of your responses. I have another (related) question. I am attempting to post a form to itself. Let me back up. Right now I am displaying 6 columns using PHP and MySQL. and I want to give the user the ability to sort these results however they want. I am using a select list in a little form to post what the user wants to sort by. It works 100% fine when I use "get", but when I try to use "post" it only works sometimes. Is there something I am doing wrong?

Here are some snippets of the code where I am having trouble (FYI the name of the page is "siteInfo.html").

This is the form used to post the user selection:

<form action="siteInfo.html" id="inputForm" method="post">
					<select  class="select" name="sort" onchange="this.form.submit()">
						<option value="entryDate">Entry Date</option>";
						<option value="pageName">Page Name</option>";
						<option value="title">Title</option>";
						<option value="information">Information</option>";
						<option value="display">Display</option>";
					</select>
				</form>

Then later on down the page this is where the previous post from the form is read in:

<?php
                                        $sort = $_POST['sort'];
					include 'php/loginInfo.php'; 

					$link = mysql_connect($host, $user, $pass) or die(mysql_error());
					mysql_select_db($dbName) or die(mysql_error());	
					
					if(isset($sort)){
						$result = mysql_query('SELECT siteInfoId, entryDate, title, information, pageName, display FROM siteInfo, page WHERE page.pageId = siteInfo.pageId ORDER BY '.$sort.' desc');
					}else{
						$result = mysql_query('SELECT siteInfoId, entryDate, title, information, pageName, display FROM siteInfo, page WHERE page.pageId = siteInfo.pageId ORDER BY entryDate desc');
					}
					
					unset($sort);
                                  ?>

And then farther down the page I have this for debugging, it seems that the form is not posting everytime based on the results from this debug, but who knows:

<?php
					//FOR DEBUGGING, DELETE!!!!!!!
					if(isset($sort)){
						echo 'SELECT siteInfoId, entryDate, title, information, pageName, display FROM siteInfo, page WHERE page.pageId = siteInfo.pageId ORDER BY '.$sort.' desc';
					}else{
						echo 'Not Read!!! <br />';
						echo 'SELECT siteInfoId, entryDate, title, information, pageName, display FROM siteInfo, page WHERE page.pageId = siteInfo.pageId ORDER BY entryDate desc';
					}
					
					unset($sort);
					
					
					mysql_close($link);
				?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.