Ben Phelps Posted November 5, 2006 Share Posted November 5, 2006 Is there a way to load variables into a html form from a config file. Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/ Share on other sites More sharing options...
alpine Posted November 5, 2006 Share Posted November 5, 2006 Is this what you are asking ? ?[code]<?php // e.g. this is the config file included by: require("config.php");$var = "value";?><form><input type="text" value="<?php echo $var; ?>" /></form>[/code] Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119864 Share on other sites More sharing options...
Ben Phelps Posted November 5, 2006 Author Share Posted November 5, 2006 Yes, on 1 part.Now how would i load a selected value into a List. Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119873 Share on other sites More sharing options...
trq Posted November 5, 2006 Share Posted November 5, 2006 Post you code. Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119874 Share on other sites More sharing options...
Ben Phelps Posted November 5, 2006 Author Share Posted November 5, 2006 I want to load the variable in this table/form[code]<table width='100%' cellspacing='1'> <tr> <td class='style1'><b>Script Location<br></b> <span class="description">Please make sure it starts with http:// and also it is the address of all your files ie. http://www.yoursite.com/upload/ Including trailing slash</span></td> <td class='pformright'><input name='location' type='text' id="location" size="60"></td> </tr> <tr> <td class='style1'>Site Title<br /> <span class="description">This will be the title of your site. This will be displayed in the browser window. </span></td> <td class='pformright'><input name="title" type="text" id="title" size="60" /></td> </tr> <tr> <td height="54" class='style1'><p>Max Files Size <span class="description"><br /> This should be a numeric value. The user will get an error if trying to upload a files over x megabytes.</span></p></td> <td class='pformright'><label> <input name="max" type="text" id="max" size="60" /> </label></td> </tr> <tr> <td class='style1'>Delete old files after this many days<span class="description"><br /> This should be a numeric value. Any files not downloaded after x number of day will be deleted. </span></td> <td class='pformright'><input name="old" type="text" id="old" size="60" /></td> </tr> <tr> <td class='style1'>Download timer in seconds<span class="description"><br /> The amount of time a user must wait before receiving a download link.</span></td> <td class='pformright'><input name="timer" type="text" id="timer" size="60" /></td> </tr> <tr> <td class='style1'>Email Option<span class="description"><br /> This will allow the user to email them self's the download information.</span></td> <td class='pformright'><label> <select name="email" id="email"> <option value="true" selected="selected">Yes</option> <option value="false">No</option> </select> </label></td> </tr> <tr> <td class='style1'>Description Option<br /> <span class="description">This will allow the user to add a description to the file. This description will show under the file name on the download page. </span></td> <td class='pformright'><select name="descr" id="descr"> <option value="true" selected="selected">Yes</option> <option value="false">No</option> </select></td> </tr> <tr> <td class='style1'>Language<br /> <span class="description">Choose Your Language . </span></td> <td class='pformright'><select name="lang" id="lang"> <option value="english" selected="selected">English</option> <option value="french">French</option> <option value="german">German</option> <option value="italian">Italian</option> <option value="portuguese">Portuguese</option> <option value="russian">Russian</option> <option value="spanish">Spanish</option> <option value="hacker">H4X0R</option> </select></td> </tr> <tr> <td class='style1'>Short URL<br /> <span class="style4">This will enable or disable the short url option, leave this alone unless you know what your are doing. </span></td> <td class='pformright'><select name="short" id="short"> <option value="true">Enabled </option> <option value="false" selected="selected">Disabled</option> </select></td> </tr> <tr> <td class='style1'>Admin Password<span class="description"><br /> This is the password to the admin section.</span></td> <td class='pformright'><input name="admin" type="text" id="admin_pass" size="60" /></td> </tr></table>[/code]Here are the Variables[code]<?php$lang = 'english';$is_installed = 'YES';$scripturl = 'http://osphp.net/XFH/';$ScriptTitle = 'XtraFileHostDemo';$maxfilesize = '5.5';$deleteafter = '15';$downloadtimer = '5';$emailoption = 'true';$descriptionoption = 'true';$short_url = 'false';$adminpass = 'password';?>[/code] Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119876 Share on other sites More sharing options...
alpine Posted November 5, 2006 Share Posted November 5, 2006 The solution IS my previous post, as long as your form page is a php file you can include the config file on top and echo $variables as values where you want them. Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119877 Share on other sites More sharing options...
Ben Phelps Posted November 5, 2006 Author Share Posted November 5, 2006 <option value="english" selected="selected">English</option>is now my problem, idk how to add the selected="selected" to the <option> for the value in the config file Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119879 Share on other sites More sharing options...
alpine Posted November 5, 2006 Share Posted November 5, 2006 See if you get this examples:[code]<?php// example email$eml_list = "";$eml_options = array("true"=>"Yes","false"=>"No");foreach($eml_options as $key => $value){if($emailoption == $key) $selected_eml = "selected=\"selected\""; else $selected_eml = "";$eml_list .= "<option value=\"$key\" $selected_eml>$value</option>";}echo <<<_HTML<select name="email" id="email">$eml_list</select>_HTML;// example language$lang_list = "";$lang_options = array("english","french","german","italian","portugese","russian","spanish","hacker");foreach($lang_options as $key){if($lang == $key) $selected = "selected=\"selected\""; else $selected = "";if($key == "hacker") $name = "H4X0R"; else $name = ucfirst($key);$lang_list .= "<option value=\"$key\" $selected>$name</option>";}echo <<<_HTML<select name="lang" id="lang">$lang_list</select>_HTML;?>[/code] Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119881 Share on other sites More sharing options...
Ben Phelps Posted November 5, 2006 Author Share Posted November 5, 2006 Yup, that works, thanks :) Link to comment https://forums.phpfreaks.com/topic/26213-load-variables-into-form/#findComment-119938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.