get from input without submitting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
chris98
Forum Contributor
Posts: 103
Joined: Tue Jun 11, 2013 10:47 am
Location: England, United Kingdom

get from input without submitting

Post by chris98 »

How could I get from an input without having to submit?

I.E.

This is my base url.Instead of having to go through every page and manually change the links, I think it would be easier to just add a base_url in.

Code: Select all

<?php
$base_select = "SELECT value FROM `SHN_config` WHERE `option` = 'base_url'";
$ps = $pdo->query($base_select);

?> 
	<input type="hidden" name="base_url" value="<?php echo $ps->fetchColumn(); ?>" />
Is there a way to do this using php?

I have tried this, but it doesn't appear to work.

Code: Select all

<?php
$base_select = "SELECT value FROM `SHN_config` WHERE `option` = 'base_url'";
$ps = $pdo->query($base_select);

?> 
	<input type="hidden" name="base_url" value="<?php echo $ps->fetchColumn(); ?>" />
	<?php $base_url = (isset($_POST['base_url'])) ? ($_POST['base_url']) : '' ; ?>

//Link
<li><a href='<?php echo $base_url; ?>about/'>About</a></li>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: get from input without submitting

Post by Celauran »

What is it you're trying to do?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: get from input without submitting

Post by Christopher »

There is no value $_POST['base_url']). You could do something like this:

Code: Select all

$Configuration['base_url']) = 'http://www.mysite.com/mypath/';     // maybe put this in a configuration.php file and include it.
// ...
	<?php $base_url = (isset($Configuration['base_url'])) ? ($Configuration['base_url']) : '' ; ?>
(#10850)
Post Reply