Results 1 to 8 of 8

Thread: Set more variables to URL

  1. #1
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts

    Set more variables to URL

    Hello,
    I'm currently editing a php script. The current URL is /file.php?id=2. I got an form which sets limit_rows so after refresh the url should look like /file.php?id=2&limit_rows=500
    May its cause I'm too tired but what i get out of this is /?&limit_rows=500.

    May you find whats wrong or what i forgot to add.

    Code:
    ?>
    	<center>
    	<h5>Enter number of lines you want to see.</h5>
    	<table>
    		<form action="&" method="get">
    			<input type="text" name="limit_rows" />
    				<br/>
    			<input type="submit" value="Refresh" />
    		</form>
    	</table>
    	</center>
    	<br>
    <?php
    	echo isset($_GET['limit_rows']) ? htmlspecialchars($_GET['limit_rows']) : '';
    And no, the ?> isnt wrong, i just don't wanna copy&paste a 2k line script ^^.

    Thanks for help.
    Earli.
    No ... No ... this is not possible .......

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Code:
            <form action="<?=$_SERVER["REQUEST_URI"]?>" method="get">
    That should already do the trick (because its writing the old GET-parameters into the form-address).
    timescale 0.01

  3. #3
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    Doesnt works, it redirects me to a different page (may cause some includings).
    No ... No ... this is not possible .......

  4. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Can you look in the source-code and write here what PHP added to the formular? It shouldn't be possible that it directs you to another page (maybe Echelon is doing it on missing parameters).
    timescale 0.01

  5. #5
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    Code:
    		<form action="/echelon/clientdetails.php?id=2" method="get">
    			<input type="text" name="limit_rows" />
    				<br/>
    			<input type="submit" value="Refresh" />
    		</form>
    But i get redirected to clients.php
    No ... No ... this is not possible .......

  6. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Does it also redirects you to clients.php if you type the url (/echelon/clientdetails.php?id=2) directly into the browser?
    timescale 0.01

  7. #7
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    If i type in /clientdetails?id=2&limit_rows=500 it shows 500 rows and also show up the standart value in the text box (500). So the limit_rows define when i type in by myself.
    No ... No ... this is not possible .......

  8. #8
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    Well okay, i made some changes and the problem is may the overgiving of the URL.
    Yes, i messed the code a littlebit up but i get my outputs that tells me that everything should be allright.
    Code:
    	$newURL = $_SERVER["REQUEST_URI"];
    	echo $newURL;
    	
    	$_GET['limit_rows'] = 500;
    Sets the actualy URL and output it, also sets the limit rows to 500 (to test)
    Output:
    Code:
    /echelon/clientdetails.php?id=2
    next parts:
    Code:
    	$newURL .= "&limit_rows=".$_GET['limit_rows'];
    	
    	echo $newURL;
    	echo "<br>";
    	
    	if(isset($_GET['limit_rows']))
    	{
    		$newURL .= "&limit_rows=".$_GET['limit_rows'];
    
    		echo isset($newURL) ? htmlspecialchars($newURL) : '';
    	}
    Outputs:
    Code:
    /echelon/clientdetails.php?id=2&limit_rows=500
    /echelon/clientdetails.php?id=2&limit_rows=500&limit_rows=500
    Even the second line works fine if i set it manually to the url.

    Actually Form:
    Code:
    	<center>
    		<h5>Enter number of lines you want to see.</h5>
    		<!--<form action="<?//=$_SERVER["REQUEST_URI"]?>" method="get">-->
    		<form action="<?php $newURL ?>" method="get">
    			<input type="text" name="limit_rows" value="<?php echo $limit_rows?>" onblur="if(this.value == ''){ this.value = '<?php echo $limit_rows?>'; }" onfocus="if(this.value == '<?php echo $limit_rows?>'){ this.value = '';}" />
    				<br/>
    			<input type="submit" value="Refresh" />
    		</form>
    	</center>
    	<br>
    So the URL is fine, the overgive of the URL should be fine, the old one should output the same. Idk whats wrong at here, i still get redirected to clients.php if i click on the refresh button.

    Any ideas?

    And btw, I'm working now 3 hours on this error ^^
    Last edited by Earliboy; 30th January 2013 at 02:37.
    No ... No ... this is not possible .......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •