wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
How to get full path in directory view in WWW
wildteen88 replied to macguy's topic in Apache HTTP Server
Have a look in to the HeaderName directive. The index file Apache produces has many configuration options. -
[SOLVED] Three forms on one page: Clearing each others input.
wildteen88 replied to webmaster1's topic in PHP Coding Help
Because mysql_real_escape_string should only used on strings and nothing else. $mileagem and $milagekm only contain numbers and nothing else. No SQL Injection can be performed from just numbers. Umm, I didn't see those lines. For now just change those to your new variable names. -
No, better to use mysql_real_escape_string in this situation.
-
$text_ad = stripslashes($row['text_ad']); should be $text_ad = mysql_real_escape_string($row['text_ad']);
-
The way you're using the foreach is completely incorrect. However looking at the code you don't even need the foreach loop. What are you trying to do?
-
Yea, how I just showed you. There is no other way... other than: <input type="checkbox" name="multiple_choice[0]" <?php if(isset($_POST['multiple_choice'][0])) echo 'checked="checked" '; ?>/> <input type="checkbox" name="multiple_choice[1]" <?php if(isset($_POST['multiple_choice'][1])) echo 'checked="checked" '; ?>/> <input type="checkbox" name="multiple_choice[2]" <?php if(isset($_POST['multiple_choice'][2])) echo 'checked="checked" '; ?>/> <input type="checkbox" name="multiple_choice[3]" <?php if(isset($_POST['multiple_choice'][3])) echo 'checked="checked" '; ?>/> <input type="checkbox" name="multiple_choice[4]" <?php if(isset($_POST['multiple_choice'][4])) echo 'checked="checked" '; ?>/> But that is just very repetitive, Which is why I opted to use an array for generating my checkboxes in my example. <?php $choices = array('Chocolate', 'Milk', 'Candy', 'Apple', 'Coca Cola'); echo 'What do you like?<br />'; foreach($choices as $key => $choice) { $chkd = (isset($_POST['multiple_choice'][$key])) ? 'checked="checked" ' : null; echo '<input type="checkbox" name="multiple_choice['.$key.']" value="'.$choice.'" '.$chkd.'/> '.$choice."<br />\n"; } ?>
-
The format for your query should be mysql_query("UPDATE tablename set column_name=column_name+1 where id = '$playerid'"); Does $type hold a column name?
-
Example: <?php if(isset($_POST['submit'])) { echo '<p><b>You chose:</b> ' . implode(', ', $_POST['multiple_choice']) . '</p>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <?php $choices = array('Chocolate', 'Milk', 'Candy', 'Apple', 'Coca Cola'); echo 'What do you like?<br />'; foreach($choices as $key => $choice) { $chkd = (isset($_POST['multiple_choice'][$key])) ? 'checked="checked" ' : null; echo '<input type="checkbox" name="multiple_choice['.$key.']" value="'.$choice.'" '.$chkd.'/> '.$choice."<br />\n"; } ?> <input type="submit" name="submit" value="Submit" /> </form>
-
[SOLVED] Three forms on one page: Clearing each others input.
wildteen88 replied to webmaster1's topic in PHP Coding Help
What I'd do is just have one form field for entering the total mileage, eg 10,000. Next to that field I'd have a list which specifies the unit, eg Miles or Kilometers. What you're now need to do in your script is work out the opposite mileage based on what the user entered. Eg if the user entered Miles then you'll need to populate the Kilometers data field for the database and vise versa for Kilometers to Miles. To do this Change: if (strlen($_POST['mileagem']) > 0) {$mileagem=TRUE; if (is_numeric($_POST['mileagem'])) {$mileagemnumericcheck=TRUE;} else {$mileagemnumericcheck=FALSE; $message_mileagemnumericcheck=" *Please enter numeric values only! (e.g. Do not input commas or the mile symbol!)"; //echo "$message_mileagemnumericcheck"; } } else {$mileagem=FALSE; $message_mileagem=" *You forgot to enter the mileage in miles!";} if (strlen($_POST['mileagekm']) > 0) {$mileagekm=TRUE; if (is_numeric($_POST['mileagekm'])) {$mileagekmnumericcheck=TRUE;} else {$mileagekmnumericcheck=FALSE; $message_mileagekmnumericcheck=" *Please enter numeric values only! (e.g. Do not input commas or the kilometre symbol!)"; //echo "$message_mileagekmnumericcheck"; } } else {$mileagekm=FALSE; $message_mileagekm=" *You forgot to enter the mileage in kilometres!";} to: $milage_unit_options = array('Miles', 'Kilometers'); if( array_key_exists($_POST['mileageu'], $milage_unit_options) ) { if (is_numeric($_POST['mileagev']) && $_POST['mileagev'] > 0) { $mileagecheck = TRUE; // convertion take place here switch($_POST['mileageu']) { // user entered Miles case 0: $mileagem = $_POST['mileagev']; // we need to work out the kilometers $mileagekm = $mileagem*1.609; break; // user entered Kilometers case 1: $mileagekm = $_POST['mileagev']; // we need to work out the milage $mileagem = $mileagekm/1.609; break; } /*echo $mileagem . ' Miles<br />'; echo $mileagekm . ' Kilometers';*/ } else { $mileagecheck = FALSE; $message_mileagecheck = " *Please enter numeric values only! (e.g. Do not input commas or the mile symbol!)"; //echo "$message_mileagenumericcheck"; } } else { $mileagecheck = FALSE; $message_mileagecheck = " *Please ensure you have choosen Miles or Kilometers from the list provided"; //echo "$message_mileagenumericcheck"; } Next remove the following lines: $mileagem = mysql_real_escape_string($_POST['mileagem']); $mileagekm = mysql_real_escape_string($_POST['mileagekm']); Lastly change <li> <label for="mileagem">Mileage M:</label> <input type="text" name="mileagem" id="mileagem" class="text" value="<?php if (isset($_POST['mileagem'])) echo $_POST['mileagem']; ?>"/> <?php if ($message_mileagem) echo ''.$message_mileagem.''; ?> <?php if ($message_mileagemnumericcheck) echo ''.$message_mileagemnumericcheck.''; ?> </br> </li> <li> <label for="mileagekm">Mileage KM:</label> <input type="text" name="mileagekm" id="mileagekm" class="text" value="<?php if (isset($_POST['mileagekm'])) echo $_POST['mileagekm']; ?>"/> <?php if ($message_mileagekm) echo ''.$message_mileagekm.''; ?> <?php if ($message_mileagemnumericcheck) echo ''.$message_mileagemnumericcheck.''; ?> </br> </li> to <li> <label for="mileage">Mileage:</label> <input type="text" name="mileagev" id="mileagev" class="text" value="<?php if (isset($_POST['mileagev'])) echo $_POST['mileagev']; ?>"/> <select name="mileageu"> <?php $options = array('Miles', 'Kilometers'); foreach($options as $key => $value) { $selected = (isset($_POST['milageu']) && $_POST['milageu'] == $key) ? ' selected="selected"' : null; echo ' <option value="'.$key.'"'.$selected.'>'.$value."</option>\n"; } ?> </select> <?php if (isset($message_mileage)) echo $message_mileage; ?> <?php if (isset($message_mileagecheck)) echo $message_mileagecheck; ?> </br> </li> The script should automatically work out the opposite mileage without the user specifying it. -
I expect it is part of phpBB's template engine. For something similar look into smarty
-
[SOLVED] Three forms on one page: Clearing each others input.
wildteen88 replied to webmaster1's topic in PHP Coding Help
of course my code wont work with your code. Mine is just an example of how to archive what you're tying to do with just one form rather than three forms. What are you tying to do? I cannot see where you are wanting to convert mileage to kilometres and vies versa -
[SOLVED] Three forms on one page: Clearing each others input.
wildteen88 replied to webmaster1's topic in PHP Coding Help
Do you mean I should inserts forms within a form? I think I'll run into the same problem with the input being cleared. If you meant I should insert the code and the fields I'm not sure how to implement an onclick event (on a regular button rather than a submit button) that will trigger my php calculation. Should I just consider using javascript to make this a standalone calculation? Did you miss my post earlier? -
[SOLVED] Three forms on one page: Clearing each others input.
wildteen88 replied to webmaster1's topic in PHP Coding Help
Yes just need one form with only three inputs, The first of which will be the distance, the second will be list of conventions the last one will be your submit button. <?php $dist = null; if(isset($_POST['submit'])) { $dist = $_POST['distance']; switch($_POST['action']) { // Miles to Kilometers case 0: $unit = ' Kilometers'; $result = $dist*1.609; break; // Kilometers to Miles case 1: $unit = ' Miles'; $result = $dist/1.609; break; } // display the result. echo number_format($result, 2, '.', ',') . $unit; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="distance" value="<?php echo $dist; ?>" /> <select name="action"> <?php $actions = array('Miles to Kilometers', 'Kilometers to Miles'); foreach($actions as $key => $action) { $selected = (isset($_POST['action']) && $_POST['action'] == $key) ? ' selected="selected"' : null; echo ' <option value="'.$key.'"'.$selected.'>'.$action."</option>\n"; } ?> </select> <input type="submit" name="submit" value="Convert"> </form> -
[SOLVED] Copy a database in wamp server to another computer?
wildteen88 replied to limitphp's topic in PHP Coding Help
Yes login to phpmyadmin. Select a database and click the export tab at the top. To setup your database on your other computer, login to phpmyadmin on that system. Then create a new database, followed by selecting the Import tab. -
The only thing I can see which can slow the script down is if the request to and from http://vle.tameside.ac.uk is slow. The code is fine tho.
-
It should of come with Apache. It is located within the bin/ folder of your Apache installation. Make sure you are using the latest version of Apache from http://httpd.apache.org
-
Please wrap any code posted within code tags -- I have done this for you. Also it would be helpful if you described what you're trying to do too.
-
Use the ApacherMonitor.exe to start/stop/restart Apache. You'll need to to run ApacherMonitor.exe as an administrator in order for it to function though.
-
To archive what you're tying to do only requires a few small changes to your code. First add // split the $images array into separate arrays containing 6 images // see http://php.net/array-chunk for documentation $pages = array_chunk($images, 6); // get the request page $page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page']-1 : 0; After the following while(false!== ($file = readdir($handle))) { if($file!= '.' && $file!= '..' &&!is_dir($file) && in_array(substr($file,-4),$extensions)) { $images[] = $file; } } } Next change if(count($images)>0) { $i=1; foreach($images as $image) { to if(count($pages[$page]) > 0) { $i=1; foreach($pages[$page] as $image) Now to add your page links change echo "</tr>\n</table>\n"; to echo "</tr>\n<tr>\n<td colspan=\"3\" align=\"center\">Page: "; for($i = 0, $p = count($pages); $i < $p; $i++) echo ' <a href="?page='.($i+1).'">'.($i+1) .'</a>'; echo "</td>\n</tr>\n</table>";
-
Cannot start apache: "the requested operation has failed!"
wildteen88 replied to n1ll0's topic in Apache HTTP Server
What OS are you using? I assume you're using Windows Vista? If that is the case then try running Apache Services Monitor as an administrator instead (do this by going to where Apache is installed. Now open the bin/ folder and right click on ApacheMonitor.exe and select Run as Administrator). -
Designed in DW tried to upload...
wildteen88 replied to Lee-Bartlett's topic in Editor Help (PhpStorm, VS Code, etc)
Make sure DW uploaded all files and not just your .php page. Also if you posted a link to your site that would be helpful. -
use Ip address instead of localhost in WAMP server
wildteen88 replied to zohaib's topic in Apache HTTP Server
http://localhost/ http://127.0.0.1/ http://192.168.1.22/ should all work without any configuration. -
Your using file_get_contents incorrectly. Your code should be $file = "test.html"; echo file_get_contents($file);
-
If you're using this version here Then enter each word to search for on a separate line.