PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 2nd, 2012, 05:48 AM
ranura ranura is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 6 ranura User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 19 sec
Reputation Power: 0
How to keep value received through GET method?

I want to keep the value "$aut_id" which is received through GET method.
It is destroyed (as usual) when I click the submit button.
Insert query needs "$aut_id" value after the clicking of submit button.
How can I achieve this?
Following is my code

Code:
<?php
	mysql_connect("localhost", "root", "123") or die (mysql_error ());
	mysql_select_db("popup_comment_box") or die(mysql_error());

	$name=$_POST['name'];
	$comment=$_POST['comment'];
	$submit=$_POST['submit'];
	$aut_id=$_GET['aut_id'];
	
	if($submit){
		if($name&&$comment){
			$query = "INSERT INTO tbl_comments 
			(name, comment, timestamp, aut_id) 
			SELECT '$name', '$comment', NOW(), aut_id 
			FROM tbl_automobile 
			WHERE aut_id = '$aut_id' LIMIT 1";
			
			mysql_query($query)  or die(mysql_error());
			
			echo "Your comment is successfully posted"."<br />";
			
		}else{
			echo "Please fill out all fields"."<br />";
		}
	}
?>
<html>
	<head>
	</head>

	<body>
		<form action="popup.php" enctype="multipart/form-data" method="post">
			<table>
				<tr><td>Name: <br><input type="text" name="name"/></td></tr>
				<tr><td>Comment: </td></tr>
				<tr><td><textarea name="comment" rows="10" cols="50"></textarea></td></tr>
				<tr>
					<td>
						<input type='submit' name='submit' value='Comment'>
					</td>
				</tr>
			</table>
		</form>
		
		<?php
			$strSQL = "SELECT * FROM tbl_comments ORDER BY comment_id DESC";
			$rs = mysql_query($strSQL) or die(mysql_error());
			while($row = mysql_fetch_array($rs)){
		?>
			<table width="430px">
			<tr>
				<td colspan="2" valign="top">
					<?php
						echo "by "."<i>".$row['name']."</i>";
					?>
				</td>
			</tr>
			<tr>
				<td valign="top">
					<?php
						echo $row['comment'];
					?>
				</td>
				<td valign="top">
					<?php
						echo "<p align='right'>".$row['timestamp']."</p>";
					?>
				</td>
			</tr>
			<tr>
				<td colspan="2" valign="top">
					<?php
						echo "Foreign key "."<i>".$row['aut_id']."</i>";
					?>
				</td>
			</tr>
			<hr size="1"/>
		</table>
		
		<?php } ?>
			
			
	</body>

</html>

Last edited by ranura : December 2nd, 2012 at 05:51 AM. Reason: body issue

Reply With Quote
  #2  
Old December 6th, 2012, 01:53 PM
COBOLdinosaur COBOLdinosaur is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Location: Canada
Posts: 6 COBOLdinosaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 47 sec
Reputation Power: 0
Just add a hidden field to the form and populate it from $aut_id with the onclick event of the submit button.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > How to keep value received through GET method?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap