Page 1 of 1

get from input without submitting

Posted: Sat Sep 28, 2013 4:20 am
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>

Re: get from input without submitting

Posted: Sat Sep 28, 2013 6:38 am
by Celauran
What is it you're trying to do?

Re: get from input without submitting

Posted: Sat Sep 28, 2013 10:41 am
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']) : '' ; ?>